ConsoleTerminateEvent.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Console\Event;
  11. use Symfony\Component\Console\Command\Command;
  12. use Symfony\Component\Console\Input\InputInterface;
  13. use Symfony\Component\Console\Output\OutputInterface;
  14. /**
  15. * Allows to manipulate the exit code of a command after its execution.
  16. *
  17. * @author Francesco Levorato <git@flevour.net>
  18. */
  19. final class ConsoleTerminateEvent extends ConsoleEvent
  20. {
  21. /**
  22. * @var int
  23. */
  24. private $exitCode;
  25. /**
  26. * @param \Symfony\Component\Console\Command\Command $command
  27. * @param \Symfony\Component\Console\Input\InputInterface $input
  28. * @param \Symfony\Component\Console\Output\OutputInterface $output
  29. * @param int $exitCode
  30. */
  31. public function __construct($command, $input, $output, $exitCode)
  32. {
  33. parent::__construct($command, $input, $output);
  34. $this->setExitCode($exitCode);
  35. }
  36. /**
  37. * @param int $exitCode
  38. */
  39. public function setExitCode($exitCode)
  40. {
  41. $this->exitCode = $exitCode;
  42. }
  43. public function getExitCode()
  44. {
  45. return $this->exitCode;
  46. }
  47. }