ConsoleTerminateEvent.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. class ConsoleTerminateEvent extends ConsoleEvent
  20. {
  21. /**
  22. * The exit code of the command.
  23. *
  24. * @var int
  25. */
  26. private $exitCode;
  27. public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode)
  28. {
  29. parent::__construct($command, $input, $output);
  30. $this->setExitCode($exitCode);
  31. }
  32. /**
  33. * Sets the exit code.
  34. *
  35. * @param int $exitCode The command exit code
  36. */
  37. public function setExitCode($exitCode)
  38. {
  39. $this->exitCode = (int) $exitCode;
  40. }
  41. /**
  42. * Gets the exit code.
  43. *
  44. * @return int The command exit code
  45. */
  46. public function getExitCode()
  47. {
  48. return $this->exitCode;
  49. }
  50. }