ConsoleTerminateEvent.php 1.2 KB

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