If an event dispatcher has been attached to the application,
events are also dispatched during the life-cycle of the command.
protected doRunCommand ( |
||
$command | A Command instance | |
$input | Symfony\Component\Console\Input\InputInterface | An Input instance |
$output | Symfony\Component\Console\Output\OutputInterface | An Output instance |
return | integer | 0 if everything went fine, or an error code |
/** * @override * @inheritDoc */ protected function doRunCommand(SymfonyCommand $command, InputInterface $input, OutputInterface $output) { if ($command instanceof CommandInterface && $command->isAsync() === true) { $this->async = true; } return parent::doRunCommand($command, $input, $output); }
/** * @inheritdoc */ protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { if ($command->getName() != 'version') { $output->writeln($this->getLongVersion()); } return parent::doRunCommand($command, $input, $output); }
/** * Pass the container to Container Aware Command classes * * @param Command $command * @param InputInterface $input * @param OutputInterface $output * @return mixed */ protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { if ($command instanceof ContainerAwareInterface) { $command->setContainer($this->getContainer()); } return parent::doRunCommand($command, $input, $output); }
/** * @param Command $command * @param InputInterface $input * @param OutputInterface $output * @return int * @throws \Exception */ protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { if ($command instanceof FactoryAwareInterface) { $command->setFactory($this->factory); } return parent::doRunCommand($command, $input, $output); }
/** * {@inheritdoc} */ public function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { // Inject the kernel in to the command before we execute it. if ($command instanceof CommandInterface) { $command->setKernel($this->kernel); } return parent::doRunCommand($command, $input, $output); }
/** * Runs the current command. * * If an event dispatcher has been attached to the application, * events are also dispatched during the life-cycle of the command. * * @param SingletonCommand $command A Command instance * @param InputInterface $input An Input instance * @param OutputInterface $output An Output instance * * @return int 0 if everything went fine, or an error code * * @throws \Exception when the command being run threw an exception */ protected function doRunCommand(SingletonCommand $command, InputInterface $input, OutputInterface $output) { try { $command->lock(); return parent::doRunCommand($command, $input, $output); } catch (\Exception $e) { $command->unlock(); } }
/** * {@inheritdoc} */ protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { if (!in_array($command->getName(), ['help', 'list'])) { $output = new ConsoleOutput($output->getVerbosity(), $output->isDecorated(), $output->getFormatter()); } if ($command instanceof \Cawa\Console\Command) { $command->setInput($input); $command->setOutput($output); } return parent::doRunCommand($command, $input, $output); }
protected function doRunCommand(BaseCommand $command, InputInterface $input, OutputInterface $output) { if (!$command instanceof Command) { return parent::doRunCommand($command, $input, $output); } $run = array_merge($this->resolveDependencies($command), [$command]); $exitCode = 0; foreach ($run as $command) { $output->writeln("Running {$command->getName()}..."); $exitCode = parent::doRunCommand($command, $input, $output); } return $exitCode; }
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { if ($input->hasParameterOption(['--log', '-l']) && $command instanceof \App\Command) { $logPath = $input->getParameterOption(['--log', '-l']); $logDir = realpath(dirname($logPath)); if (!$logDir) { throw new \InvalidArgumentException(sprintf('Log folder does not exist! %s', $logDir)); } $log = new Logger('depipe'); $log->pushHandler(new StreamHandler($logPath)); $command->setLogger($log); $this->logger = $command; } parent::doRunCommand($command, $input, $output); }
/** * {@inheritDoc} */ public function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { if ($command instanceof ContainerAwareInterface) { $container = $this->buildContainer($input); $command->setContainer($container); } return parent::doRunCommand($command, $input, $output); }
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { $this->getHelperSet()->setCommand($command); return parent::doRunCommand($command, $input, $output); }
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { if ($this->serviceLocator) { $this->serviceLocator->callInjects($command); } return parent::doRunCommand($command, $input, $output); }
/** * @override To limit access as root user */ public function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { if ($this->isRunByRoot() && !$this->isWhitelistedForRoot($command)) { $output->writeln('<error>You are not allowed to run this command as root.</error>'); return ExitCode::EXIT_COMMAND_AS_ROOT_DENIED; } return parent::doRunCommand($command, $input, $output); }
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { if ($command instanceof \Owncloud\Updater\Command\Command) { $command->setContainer($this->getContainer()); $commandName = $this->getCommandName($input); $this->getLogger()->info('Execution of ' . $commandName . ' command started'); if (!empty($command->getMessage())) { $message = sprintf('<info>%s</info>', $command->getMessage()); $output->writeln($message); } $exitCode = parent::doRunCommand($command, $input, $output); $this->getLogger()->info('Execution of ' . $commandName . ' command stopped. Exit code is ' . $exitCode); } else { $exitCode = parent::doRunCommand($command, $input, $output); } return $exitCode; }
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { $definition = $command->getDefinition(); $definition->addOption(new InputOption('gruver_file', 'g', InputOption::VALUE_OPTIONAL, 'Location of gruver.yml file')); return parent::doRunCommand($command, $input, $output); }
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { $name = $command->getName(); $name = strtr($name, ":", "."); $logger = new LocalFileHandler($this->getLoggingPath(), "%date%/%script%.{$name}.log", $this->getLoggingLevel()); $logger->install(); $logger = new LocalErrorHandler($this->getLoggingPath(), "%date%/%script%.{$name}.error", $this->getLoggingLevel()); $logger->install(); return parent::doRunCommand($command, $input, $output); }
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { if (!$command instanceof LocalCommand\NeedConfigurationInterface) { return parent::doRunCommand($command, $input, $output); } $configuration = $this->getHelperSet()->get('configuration')->getConfiguration($input, $output); $this->apiConfig = array_merge($this->apiConfig, $configuration->toArray()); if (false !== $input->getParameterOption('--log')) { $this->logFile = $input->getParameterOption('--log') ?: getcwd() . '/insight.log'; } return parent::doRunCommand($command, $input, $output); }
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { $storagePath = getenv('INSIGHT_HOME'); if (!$storagePath) { if (defined('PHP_WINDOWS_VERSION_MAJOR')) { if (!getenv('APPDATA')) { throw new \RuntimeException('The APPDATA or INSIGHT_HOME environment variable must be set for insight to run correctly'); } $storagePath = strtr(getenv('APPDATA'), '\\', '/') . '/Sensiolabs'; } else { if (!getenv('HOME')) { throw new \RuntimeException('The HOME or INSIGHT_HOME environment variable must be set for insight to run correctly'); } $storagePath = rtrim(getenv('HOME'), '/') . '/.sensiolabs'; } } if (!is_dir($storagePath) && !@mkdir($storagePath, 0777, true)) { throw new \RuntimeException(sprintf('The directory "%s" does not exist and could not be created.', $storagePath)); } if (!is_writable($storagePath)) { throw new \RuntimeException(sprintf('The directory "%s" is not writable.', $storagePath)); } $configPath = $storagePath . '/insight.json'; $config = array('api_token' => null, 'user_uuid' => null, 'api_endpoint' => Api::ENDPOINT); if (file_exists($configPath)) { $config = array_replace($config, json_decode(file_get_contents($configPath), true)); } $newConfig = array('api_token' => $this->getValue($input, $output, '--api-token', 'INSIGHT_API_TOKEN', 'api token', $config['api_token']), 'user_uuid' => $this->getValue($input, $output, '--user-uuid', 'INSIGHT_USER_UUID', 'user uuid', $config['user_uuid']), 'api_endpoint' => $this->getValue($input, $output, '--api-endpoint', 'INSIGHT_API_ENDPOINT', 'api endpoint', $config['api_endpoint'])); if ($config !== $newConfig && $input->isInteractive()) { $dialog = $this->getHelperSet()->get('dialog'); if ($dialog->askConfirmation($output, sprintf('Do you want to store your configuration in "%s" <comment>[y/N]</comment>?', $storagePath), false)) { file_put_contents($configPath, json_encode($newConfig)); } } $this->apiConfig = array_merge($this->apiConfig, $newConfig); if (false !== $input->getParameterOption('--log')) { $this->logFile = $input->getParameterOption('--log') ?: getcwd() . '/insight.log'; } return parent::doRunCommand($command, $input, $output); }
/** * {@inheritDoc} */ protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { if ($command instanceof \Composer\Command\BaseCommand) { if (!$command instanceof SelfUpdateCommand) { $command->setComposer(ComposerFactory::create($this->inputOutput)); } $command->setIO(new ConsoleIO($input, $output, $this->getHelperSet())); } return parent::doRunCommand($command, $input, $output); }
/** * @author Ronan Chilvers <*****@*****.**> */ protected function doRunCommand(SymfonyCommand $command, InputInterface $input, OutputInterface $output) { $output->writeLn('<info>git-hook : ' . $command->getName() . '</info>'); return parent::doRunCommand($command, $input, $output); }
/** * {@inheritdoc} */ protected function doRunCommand(ConsoleCommand $command, InputInterface $input, OutputInterface $output) { $this->setCurrentCommand($command); // Build the command synopsis early, so it doesn't include default // options and arguments (such as --help and <command>). // @todo find a better solution for this? $this->currentCommand->getSynopsis(); return parent::doRunCommand($command, $input, $output); }