當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。