當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。