本文整理汇总了PHP中Symfony\Component\Console\Event\ConsoleExceptionEvent::getExitCode方法的典型用法代码示例。如果您正苦于以下问题:PHP ConsoleExceptionEvent::getExitCode方法的具体用法?PHP ConsoleExceptionEvent::getExitCode怎么用?PHP ConsoleExceptionEvent::getExitCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Event\ConsoleExceptionEvent
的用法示例。
在下文中一共展示了ConsoleExceptionEvent::getExitCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onConsoleException
/**
* Logs console exception
*
* @param ConsoleExceptionEvent $event The event
*
* @return void
*/
public function onConsoleException(ConsoleExceptionEvent $event)
{
$exception = $event->getException();
$exitCode = $event->getExitCode();
$message = sprintf('%s: "%s" at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine());
$this->logger->error($message, ['exit_code' => $exitCode, 'exception' => $exception]);
}
示例2: onConsoleException
/**
* @param ConsoleExceptionEvent $event
*/
public function onConsoleException(ConsoleExceptionEvent $event)
{
$exception = $event->getException();
$metadata = new Metadata();
$metadata->addMetadatum('commandName', $event->getInput()->getFirstArgument());
$metadata->addMetadatum('command', (string) $event->getInput());
$metadata->addMetadatum('exitCode', $event->getExitCode());
$this->errorHandler->handleException($exception, $metadata);
}
示例3: doRunCommand
/**
* 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 Command $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
*/
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
{
foreach ($command->getHelperSet() as $helper) {
if ($helper instanceof InputAwareInterface) {
$helper->setInput($input);
}
}
if (null === $this->dispatcher) {
return $command->run($input, $output);
}
$event = new ConsoleCommandEvent($command, $input, $output);
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
try {
$exitCode = $command->run($input, $output);
} catch (\Exception $e) {
$event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode());
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
$event = new ConsoleExceptionEvent($command, $input, $output, $e, $event->getExitCode());
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
throw $event->getException();
}
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
return $event->getExitCode();
}
示例4: doRunCommand
/**
* {@inheritdoc}
*/
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
{
$helperSet = $command->getHelperSet();
foreach ($helperSet as $helper) {
if ($helper instanceof OutputAwareInterface) {
$helper->setOutput($output);
}
if ($helper instanceof InputAwareInterface) {
$helper->setInput($input);
}
}
$event = new ConsoleCommandEvent($command, $input, $output);
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
try {
$exitCode = $command->run($input, $output);
} catch (\Exception $e) {
$event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode());
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
$event = new ConsoleExceptionEvent($command, $input, $output, $e, $event->getExitCode());
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
if ($e instanceof UserException) {
$this->getHelperSet()->get('gush_style')->error($e->getMessages());
if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
throw $e;
}
return $event->getExitCode();
} else {
throw $event->getException();
}
}
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
return $event->getExitCode();
}
示例5: onConsoleException
/**
* @param \Symfony\Component\Console\Event\ConsoleExceptionEvent $event
*/
public function onConsoleException(ConsoleExceptionEvent $event)
{
$this->campfire->notifyOnConsoleException($event->getInput(), $event->getOutput(), $event->getException(), $event->getExitCode());
}