all() public method

public all ( $namespace = null )
Example #1
0
 public function testBundleCommandsAreRetrievable()
 {
     $bundle = $this->createBundleMock(array());
     $kernel = $this->getKernel(array($bundle));
     $application = new Application($kernel);
     $application->all();
     // Calling twice: registration should only be done once.
     $application->all();
 }
Example #2
0
 public function testBundleCommandsAreRetrievable()
 {
     $bundle = $this->getMock('Symfony\\Component\\HttpKernel\\Bundle\\Bundle');
     $bundle->expects($this->once())->method('registerCommands');
     $kernel = $this->getKernel(array($bundle));
     $application = new Application($kernel);
     $application->all();
     // Calling twice: registration should only be done once.
     $application->all();
 }
 /**
  * @param $commandName
  * @param string $kernelName
  * @return CommandHelper
  */
 protected static function commandHelper($commandName, $kernelName = 'default')
 {
     $application = new Application($kernel = static::getSharedKernel($kernelName));
     $container = $kernel->getContainer();
     foreach ($application->all() as $command) {
         if ($command instanceof ContainerAwareInterface) {
             $command->setContainer($container);
         }
     }
     $application->setDispatcher($container->get('event_dispatcher'));
     return new CommandHelper($container, $application->find($commandName));
 }
Example #4
0
 /**
  * Execute a symfony command.
  *
  * $this->executeCommand('sulu:security:user:create', array(
  *     'firstName' => 'foo',
  *     '--option' => 'bar',
  * ));
  *
  * @param string $command Command to execute
  * @param array  $args    Arguments and options
  *
  * @return int Exit code of command
  */
 protected function execCommand($command, $args)
 {
     $kernel = $this->kernel;
     array_unshift($args, $command);
     $input = new ArrayInput($args);
     $application = new Application($kernel);
     $application->all();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $command = $application->find($command);
     $output = new StreamOutput(fopen('php://memory', 'w', false));
     $exitCode = $application->run($input, $output);
     if ($exitCode !== 0) {
         rewind($output->getStream());
         $output = stream_get_contents($output->getStream());
         throw new \Exception(sprintf('Command in BaseContext exited with code "%s": "%s"', $exitCode, $output));
     }
     return $exitCode;
 }
Example #5
0
 public function consoleAction()
 {
     return new Response($this->templating->render('CoreSphereConsoleBundle:Console:console.html.twig', ['working_dir' => getcwd(), 'environment' => $this->environment, 'commands' => $this->application->all()]));
 }