当前位置: 首页>>代码示例>>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;未经允许,请勿转载。