当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::getVersion方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Application::getVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getVersion方法的具体用法?PHP Application::getVersion怎么用?PHP Application::getVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Application的用法示例。


在下文中一共展示了Application::getVersion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getApplicationDocument

 /**
  * @param Application $application
  * @param string|null $namespace
  *
  * @return \DOMDocument
  */
 public function getApplicationDocument(Application $application, $namespace = null)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->appendChild($rootXml = $dom->createElement('symfony'));
     if ($application->getName() !== 'UNKNOWN') {
         $rootXml->setAttribute('name', $application->getName());
         if ($application->getVersion() !== 'UNKNOWN') {
             $rootXml->setAttribute('version', $application->getVersion());
         }
     }
     $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
     $description = new ApplicationDescription($application, $namespace);
     if ($namespace) {
         $commandsXML->setAttribute('namespace', $namespace);
     }
     foreach ($description->getCommands() as $command) {
         $this->appendDocument($commandsXML, $this->getCommandDocument($command));
     }
     if (!$namespace) {
         $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
         foreach ($description->getNamespaces() as $namespaceDescription) {
             $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
             $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
             foreach ($namespaceDescription['commands'] as $name) {
                 $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
                 $commandXML->appendChild($dom->createTextNode($name));
             }
         }
     }
     return $dom;
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:37,代码来源:XmlDescriptor.php

示例2: getVersion

 /**
  * {@inheritdoc}
  */
 public function getVersion()
 {
     if (parent::getVersion() === null && $this->getProjectDirectory()) {
         if ($this->getPackageName()) {
             $version = $this->findPackageVersion($this->getPackageName(), $this->getProjectDirectory());
         } else {
             $version = $this->findGitVersion($this->getProjectDirectory());
         }
         $this->setVersion($version ?: 'UNKNOWN');
     }
     return parent::getVersion();
 }
开发者ID:gmo,项目名称:console,代码行数:15,代码来源:ConsoleApplication.php

示例3: describeApplication

 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     $commands = array();
     foreach ($description->getCommands() as $command) {
         $commands[] = $this->getCommandData($command);
     }
     $data = array();
     if ('UNKNOWN' !== $application->getName()) {
         $data['application']['name'] = $application->getName();
         if ('UNKNOWN' !== $application->getVersion()) {
             $data['application']['version'] = $application->getVersion();
         }
     }
     $data['commands'] = $commands;
     if ($describedNamespace) {
         $data['namespace'] = $describedNamespace;
     } else {
         $data['namespaces'] = array_values($description->getNamespaces());
     }
     $this->writeData($data, $options);
 }
开发者ID:symfony,项目名称:symfony,代码行数:26,代码来源:JsonDescriptor.php

示例4: testSetGetVersion

 public function testSetGetVersion()
 {
     $application = new Application();
     $application->setVersion('bar');
     $this->assertEquals('bar', $application->getVersion(), '->setVersion() sets the version of the application');
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:6,代码来源:ApplicationTest.php


注:本文中的Symfony\Component\Console\Application::getVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。