annotate vendor/symfony/console/Event/ConsoleExceptionEvent.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 1fec387a4317
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /*
Chris@0 4 * This file is part of the Symfony package.
Chris@0 5 *
Chris@0 6 * (c) Fabien Potencier <fabien@symfony.com>
Chris@0 7 *
Chris@0 8 * For the full copyright and license information, please view the LICENSE
Chris@0 9 * file that was distributed with this source code.
Chris@0 10 */
Chris@0 11
Chris@0 12 namespace Symfony\Component\Console\Event;
Chris@0 13
Chris@14 14 @trigger_error(sprintf('The "%s" class is deprecated since Symfony 3.3 and will be removed in 4.0. Use the ConsoleErrorEvent instead.', ConsoleExceptionEvent::class), E_USER_DEPRECATED);
Chris@14 15
Chris@0 16 use Symfony\Component\Console\Command\Command;
Chris@0 17 use Symfony\Component\Console\Input\InputInterface;
Chris@0 18 use Symfony\Component\Console\Output\OutputInterface;
Chris@0 19
Chris@0 20 /**
Chris@0 21 * Allows to handle exception thrown in a command.
Chris@0 22 *
Chris@0 23 * @author Fabien Potencier <fabien@symfony.com>
Chris@14 24 *
Chris@14 25 * @deprecated since version 3.3, to be removed in 4.0. Use ConsoleErrorEvent instead.
Chris@0 26 */
Chris@0 27 class ConsoleExceptionEvent extends ConsoleEvent
Chris@0 28 {
Chris@0 29 private $exception;
Chris@0 30 private $exitCode;
Chris@0 31
Chris@0 32 public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode)
Chris@0 33 {
Chris@0 34 parent::__construct($command, $input, $output);
Chris@0 35
Chris@0 36 $this->setException($exception);
Chris@0 37 $this->exitCode = (int) $exitCode;
Chris@0 38 }
Chris@0 39
Chris@0 40 /**
Chris@0 41 * Returns the thrown exception.
Chris@0 42 *
Chris@0 43 * @return \Exception The thrown exception
Chris@0 44 */
Chris@0 45 public function getException()
Chris@0 46 {
Chris@0 47 return $this->exception;
Chris@0 48 }
Chris@0 49
Chris@0 50 /**
Chris@0 51 * Replaces the thrown exception.
Chris@0 52 *
Chris@0 53 * This exception will be thrown if no response is set in the event.
Chris@0 54 *
Chris@0 55 * @param \Exception $exception The thrown exception
Chris@0 56 */
Chris@0 57 public function setException(\Exception $exception)
Chris@0 58 {
Chris@0 59 $this->exception = $exception;
Chris@0 60 }
Chris@0 61
Chris@0 62 /**
Chris@0 63 * Gets the exit code.
Chris@0 64 *
Chris@0 65 * @return int The command exit code
Chris@0 66 */
Chris@0 67 public function getExitCode()
Chris@0 68 {
Chris@0 69 return $this->exitCode;
Chris@0 70 }
Chris@0 71 }