本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand::run方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerAwareCommand::run方法的具体用法?PHP ContainerAwareCommand::run怎么用?PHP ContainerAwareCommand::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
的用法示例。
在下文中一共展示了ContainerAwareCommand::run方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* {@inheritdoc}
*
* @throws \RuntimeException When another task is already running.
*/
public function run(InputInterface $input, OutputInterface $output)
{
// If successfully forked, exit now as the parenting process is done.
if ($this->fork()) {
$output->writeln('Forked into background.');
return 0;
}
return parent::run($input, $output);
}
示例2: run
public function run(InputInterface $inputInterface, OutputInterface $outputInterface)
{
register_shutdown_function(array($this, 'terminate'), $inputInterface, $outputInterface);
\Amp\run(function () use($inputInterface, $outputInterface) {
\Amp\repeat(function () use($inputInterface, $outputInterface) {
if ($leaking = $this->isLeaking()) {
$this->getContainer()->get('logger')->alert('Memory leaked.', $leaking);
}
parent::run($inputInterface, $outputInterface);
}, 1);
$outputInterface->writeln('The command has <info>successfully</info> started.');
});
}
示例3: run
public function run(InputInterface $input, OutputInterface $output)
{
$start = new \DateTime();
$output->writeln('<comment>' . $this->getName() . '</comment> started at <info>' . $start->format('Y-m-d H:i:s') . '</info>');
$msg = '';
try {
$return = parent::run($input, $output);
} catch (\Exception $ex) {
$msg = '<error>FAILURE of </error>';
$this->onError($input, $output, $ex);
}
$end = new \DateTime();
$duration = Carbon::instance($start)->diffInSeconds(Carbon::instance($end));
$msg .= '<comment>' . $this->getName() . '</comment> ended at <info>' . $end->format('Y-m-d H:i:s') . '</info>. Duration is <info>' . $duration . '</info> seconds.';
$this->displayMemory($output);
$output->writeln($msg);
if (isset($ex)) {
$this->dispatch(CommandEvents::ERROR, new CommandEvent($this, array('exception' => $ex)));
throw $ex;
}
$this->dispatch(CommandEvents::TERMINATE, new CommandEvent($this));
return $return;
}
示例4: run
/**
* @param InputInterface $inputInterface
* @param OutputInterface $outputInterface
* @return int|void
* @throws \Keboola\ProvisioningBundle\Provisioning\Exception
*/
public function run(InputInterface $inputInterface, OutputInterface $outputInterface)
{
if ($this->getContainer()->hasParameter("maintenance.status") && $this->getContainer()->getParameter("maintenance.status") == true) {
throw new Exception("Maintenance");
}
return parent::run($inputInterface, $outputInterface);
}
示例5: run
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int
*
* @see Symfony\Component\Console\Command\Command::run()
*/
public function run(InputInterface $input, OutputInterface $output)
{
// Force the creation of the synopsis before the merge with the app definition
$this->getSynopsis();
// Add the signal handler
if (function_exists('pcntl_signal')) {
// Enable ticks for fast signal processing
declare (ticks=1);
pcntl_signal(SIGTERM, array($this, 'handleSignal'));
pcntl_signal(SIGINT, array($this, 'handleSignal'));
}
// And now run the command
return parent::run($input, $output);
}
示例6: run
/**
* Override framework function to add pre and post hooks around the parent functionality
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return int The command exit code
*
* @throws \Exception
* @throws BaseCommandException
*
* @see setCode()
* @see execute()
*/
public function run(InputInterface $input, OutputInterface $output)
{
$this->advanceExecutionPhase(RuntimeConfig::PHASE_PRE_RUN);
$this->preRun($output);
$this->advanceExecutionPhase(RuntimeConfig::PHASE_RUN);
$exitCode = parent::run($input, $output);
if ($this->getRuntimeConfig()->getExecutionPhase() !== RuntimeConfig::PHASE_POST_INITIALISE) {
if ($this->getRuntimeConfig()->getExecutionPhase() == RuntimeConfig::PHASE_INITIALIZE_FAILED) {
throw new BaseCommandException('It appears that you tried to continue execution despite the initialization ' . 'of the BaseCommand failing. This is a very dangerous idea as the behaviour is undefined');
} else {
throw new BaseCommandException('BaseCommand not initialized. Did you override the initialize() function ' . 'without calling parent::initialize() ?');
}
}
$this->advanceExecutionPhase(RuntimeConfig::PHASE_POST_RUN);
$this->postRun($input, $output, $exitCode);
return $exitCode;
}
示例7: run
public function run(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$result = parent::run($input, $output);
return $result;
}
示例8: runCommand
/**
* Runs a command and returns a response if there was an error.
*
* @param ContainerAwareCommand $command
* @param InputInterface|null $input
*
* @return Response|null
*/
private function runCommand(ContainerAwareCommand $command, InputInterface $input = null)
{
if (null === $input) {
$input = new ArgvInput([]);
}
$output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true);
$command->setContainer($this->container);
$status = $command->run($input, $output);
if ($status > 0) {
return $this->render('console.html.twig', ['output' => $output->fetch()]);
}
return null;
}
示例9: run
/**
* Override framework function to add pre and post hooks around the parent functionality
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return int The command exit code
*
* @throws \Exception
* @throws BaseCommandException
*
* @see setCode()
* @see execute()
*/
public function run(InputInterface $input, OutputInterface $output)
{
if (is_null($this->runtimeConfig)) {
throw new BaseCommandException("If you override the 'configure()' function, you need to call parent::configure()" . " in your overridden method in order for the BaseCommand to function correctly");
}
$this->advanceExecutionPhase(RuntimeConfig::PHASE_PRE_RUN);
$this->preRun($output);
$this->advanceExecutionPhase(RuntimeConfig::PHASE_RUN);
$exitCode = parent::run($input, $output);
if ($this->getRuntimeConfig()->getExecutionPhase() !== RuntimeConfig::PHASE_POST_INITIALISE) {
throw new BaseCommandException('BaseCommand not initialized. Did you override the initialize() function ' . 'without calling parent::initialize() ?');
}
$this->advanceExecutionPhase(RuntimeConfig::PHASE_POST_RUN);
$this->postRun($input, $output, $exitCode);
return $exitCode;
}