當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Application::findNamespace方法代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Application::findNamespace方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::findNamespace方法的具體用法?PHP Application::findNamespace怎麽用?PHP Application::findNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Console\Application的用法示例。


在下文中一共展示了Application::findNamespace方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: inspectApplication

 private function inspectApplication()
 {
     $this->commands = array();
     $this->namespaces = array();
     $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
     foreach ($this->sortCommands($all) as $namespace => $commands) {
         $names = array();
         /** @var Command $command */
         foreach ($commands as $name => $command) {
             if (!$command->getName()) {
                 continue;
             }
             if ($command->getName() === $name) {
                 $this->commands[$name] = $command;
             } else {
                 $this->aliases[$name] = $command;
             }
             $names[] = $name;
         }
         $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names);
     }
 }
開發者ID:betes-curieuses-design,項目名稱:ElieJosiePhotographie,代碼行數:22,代碼來源:ApplicationDescription.php

示例2: testFindInvalidNamespace

 /**
  * @expectedException        Symfony\Component\Console\Exception\CommandNotFoundException
  * @expectedExceptionMessage There are no commands defined in the "bar" namespace.
  */
 public function testFindInvalidNamespace()
 {
     $application = new Application();
     $application->findNamespace('bar');
 }
開發者ID:Ener-Getick,項目名稱:symfony,代碼行數:9,代碼來源:ApplicationTest.php

示例3: testFindNamespace

 public function testFindNamespace()
 {
     $application = new Application();
     $application->add(new \FooCommand());
     $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists');
     $this->assertEquals('foo', $application->findNamespace('f'), '->findNamespace() finds a namespace given an abbreviation');
     $application->add(new \Foo2Command());
     $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists');
     try {
         $application->findNamespace('f');
         $this->fail('->findNamespace() throws an \\InvalidArgumentException if the abbreviation is ambiguous');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\InvalidArgumentException', $e, '->findNamespace() throws an \\InvalidArgumentException if the abbreviation is ambiguous');
         $this->assertEquals('The namespace "f" is ambiguous (foo, foo1).', $e->getMessage(), '->findNamespace() throws an \\InvalidArgumentException if the abbreviation is ambiguous');
     }
     try {
         $application->findNamespace('bar');
         $this->fail('->findNamespace() throws an \\InvalidArgumentException if no command is in the given namespace');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\InvalidArgumentException', $e, '->findNamespace() throws an \\InvalidArgumentException if no command is in the given namespace');
         $this->assertEquals('There are no commands defined in the "bar" namespace.', $e->getMessage(), '->findNamespace() throws an \\InvalidArgumentException if no command is in the given namespace');
     }
 }
開發者ID:TeamA-ict,項目名稱:TeamA,代碼行數:23,代碼來源:ApplicationTest.php


注:本文中的Symfony\Component\Console\Application::findNamespace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。