Esempio n. 1
0
 public function testInjectKernelContainerToCommand()
 {
     $container = \Mockery::mock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $this->kernel->shouldReceive('getContainer')->andReturn($container);
     $command = new ContainerAwareCommand();
     $application = new Application($this->kernel);
     $application->add($command);
     static::assertSame($container, $command->getContainer());
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function boot(Application $application)
 {
     $container = $application->getKernel()->getContainer();
     if ($container->has($this->service)) {
         $registry = $container->get($this->service);
         foreach ($registry as $command) {
             $application->add($command);
         }
     }
 }