/** * @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)); }