ConsoleEvent.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. use Symfony\Contracts\EventDispatcher\Event;
  15. /**
  16. * Allows to inspect input and output of a command.
  17. *
  18. * @author Francesco Levorato <git@flevour.net>
  19. */
  20. class ConsoleEvent extends Event
  21. {
  22. protected $command;
  23. private InputInterface $input;
  24. private OutputInterface $output;
  25. public function __construct(?Command $command, InputInterface $input, OutputInterface $output)
  26. {
  27. $this->command = $command;
  28. $this->input = $input;
  29. $this->output = $output;
  30. }
  31. /**
  32. * Gets the command that is executed.
  33. */
  34. public function getCommand(): ?Command
  35. {
  36. return $this->command;
  37. }
  38. /**
  39. * Gets the input instance.
  40. */
  41. public function getInput(): InputInterface
  42. {
  43. return $this->input;
  44. }
  45. /**
  46. * Gets the output instance.
  47. */
  48. public function getOutput(): OutputInterface
  49. {
  50. return $this->output;
  51. }
  52. }