当前位置: 首页>>代码示例>>PHP>>正文


PHP ConsoleExceptionEvent::getExitCode方法代码示例

本文整理汇总了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]);
 }
开发者ID:novuso,项目名称:common-bundle,代码行数:14,代码来源:ExceptionLogSubscriber.php

示例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);
 }
开发者ID:prgtw,项目名称:error-handler-bundle,代码行数:12,代码来源:ExceptionListener.php

示例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();
 }
开发者ID:astronautyan,项目名称:O2OMobile_PHP,代码行数:37,代码来源:Application.php

示例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();
 }
开发者ID:gushphp,项目名称:gush,代码行数:37,代码来源:Application.php

示例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());
 }
开发者ID:ruudk,项目名称:CampfireExceptionBundle,代码行数:7,代码来源:ExceptionListener.php


注:本文中的Symfony\Component\Console\Event\ConsoleExceptionEvent::getExitCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。