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


PHP Application::has方法代码示例

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


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

示例1: match

 public function match(Request $request)
 {
     if (!$request instanceof ConsoleRequest) {
         return null;
     }
     $params = $request->getParams()->toArray();
     if (!isset($params[0]) || !$this->application->has($params[0])) {
         return null;
     }
     return new RouteMatch($this->defaults);
 }
开发者ID:alex-oleshkevich,项目名称:zf-extras,代码行数:11,代码来源:SymfonyProxyRoute.php

示例2: testArrayCallbackSyntax

 public function testArrayCallbackSyntax()
 {
     $console = new Application();
     $console->add(new LlamaCommand('test:llama-command', null, array($this, 'simpleCallback')));
     $this->assertTrue($console->has('test:llama-command'));
     $command = $console->get('test:llama-command');
     $this->assertInstanceOf('Beryllium\\Llama\\LlamaCommand', $command);
     $input = new ArrayInput(array('test:llama-command'));
     $output = new BufferedOutput();
     $command->run($input, $output);
     $this->assertSame("simple callback works\n", $output->fetch());
 }
开发者ID:beryllium,项目名称:llama,代码行数:12,代码来源:LlamaCommandTest.php

示例3: registerCommands

 public function registerCommands(Application $application)
 {
     /** @var Container $container */
     $container = $this->container;
     foreach ($container->getServiceIds() as $serviceId) {
         $name = null;
         if (strncmp($serviceId, "command.", 8) === 0) {
             $name = str_replace(".", ":", substr($serviceId, 8));
         } elseif (strncmp($serviceId, "task.", 5) === 0) {
             $name = str_replace(".", ":", $serviceId);
         }
         if ($name !== null && !$application->has($name)) {
             /** @var Command $command */
             $command = $this->container->get($serviceId);
             if ($command instanceof AbstractCommand) {
                 /** @var AbstractCommand $command */
                 $command->initializeCommand($name);
             }
             $application->add($command);
         }
     }
 }
开发者ID:skrz,项目名称:cc15-mongo-es-redis-rabbitmq,代码行数:22,代码来源:CC15Bundle.php

示例4: testHasGet

 public function testHasGet()
 {
     $application = new Application();
     $this->assertTrue($application->has('list'), '->has() returns true if a named command is registered');
     $this->assertFalse($application->has('afoobar'), '->has() returns false if a named command is not registered');
     $application->add($foo = new \FooCommand());
     $this->assertTrue($application->has('afoobar'), '->has() returns true if an alias is registered');
     $this->assertEquals($foo, $application->get('foo:bar'), '->get() returns a command by name');
     $this->assertEquals($foo, $application->get('afoobar'), '->get() returns a command by alias');
     $application = new Application();
     $application->add($foo = new \FooCommand());
     // simulate --help
     $r = new \ReflectionObject($application);
     $p = $r->getProperty('wantHelps');
     $p->setAccessible(true);
     $p->setValue($application, true);
     $command = $application->get('foo:bar');
     $this->assertInstanceOf('Symfony\\Component\\Console\\Command\\HelpCommand', $command, '->get() returns the help command if --help is provided as the input');
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:19,代码来源:ApplicationTest.php

示例5: testHasGet

 public function testHasGet()
 {
     $application = new Application();
     $this->assertTrue($application->has('list'), '->has() returns true if a named command is registered');
     $this->assertFalse($application->has('afoobar'), '->has() returns false if a named command is not registered');
     $application->add($foo = new \FooCommand());
     $this->assertTrue($application->has('afoobar'), '->has() returns true if an alias is registered');
     $this->assertEquals($foo, $application->get('foo:bar'), '->get() returns a command by name');
     $this->assertEquals($foo, $application->get('afoobar'), '->get() returns a command by alias');
     try {
         $application->get('foofoo');
         $this->fail('->get() throws an \\InvalidArgumentException if the command does not exist');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\InvalidArgumentException', $e, '->get() throws an \\InvalidArgumentException if the command does not exist');
         $this->assertEquals('The command "foofoo" does not exist.', $e->getMessage(), '->get() throws an \\InvalidArgumentException if the command does not exist');
     }
     $application = new TestApplication();
     $application->add($foo = new \FooCommand());
     $application->setWantHelps();
     $command = $application->get('foo:bar');
     $this->assertEquals('Symfony\\Component\\Console\\Command\\HelpCommand', get_class($command), '->get() returns the help command if --help is provided as the input');
 }
开发者ID:spf13,项目名称:symfony,代码行数:22,代码来源:ApplicationTest.php

示例6: testDefaultsWithOrm

 /**
  * @covers ::boot
  */
 public function testDefaultsWithOrm()
 {
     $app = new Silex();
     $app['db'] = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock();
     $app['orm.em'] = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $console = new Console();
     $app->register(new DoctrineMigrationsProvider($console));
     $this->assertFalse($console->has('migrations:execute'));
     $this->assertFalse($console->has('migrations:generate'));
     $this->assertFalse($console->has('migrations:migrate'));
     $this->assertFalse($console->has('migrations:status'));
     $this->assertFalse($console->has('migrations:version'));
     $this->assertFalse($console->has('migrations:diff'));
     $app->boot();
     $this->assertTrue($console->has('migrations:execute'));
     $this->assertTrue($console->has('migrations:generate'));
     $this->assertTrue($console->has('migrations:migrate'));
     $this->assertTrue($console->has('migrations:status'));
     $this->assertTrue($console->has('migrations:version'));
     $this->assertTrue($console->has('migrations:diff'));
 }
开发者ID:mikeSimonson,项目名称:silex-doctrine-migrations-provider,代码行数:24,代码来源:DoctrineMigrationsProviderTest.php


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