CommandEvent.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Plugin;
  12. use Composer\EventDispatcher\Event;
  13. use Symfony\Component\Console\Input\InputInterface;
  14. use Symfony\Component\Console\Output\OutputInterface;
  15. /**
  16. * An event for all commands.
  17. *
  18. * @author Nils Adermann <naderman@naderman.de>
  19. */
  20. class CommandEvent extends Event
  21. {
  22. /**
  23. * @var string
  24. */
  25. private $commandName;
  26. /**
  27. * @var InputInterface
  28. */
  29. private $input;
  30. /**
  31. * @var OutputInterface
  32. */
  33. private $output;
  34. /**
  35. * Constructor.
  36. *
  37. * @param string $name The event name
  38. * @param string $commandName The command name
  39. * @param InputInterface $input
  40. * @param OutputInterface $output
  41. * @param array $args Arguments passed by the user
  42. * @param array $flags Optional flags to pass data not as argument
  43. */
  44. public function __construct($name, $commandName, $input, $output, array $args = array(), array $flags = array())
  45. {
  46. parent::__construct($name, $args, $flags);
  47. $this->commandName = $commandName;
  48. $this->input = $input;
  49. $this->output = $output;
  50. }
  51. /**
  52. * Returns the command input interface
  53. *
  54. * @return InputInterface
  55. */
  56. public function getInput()
  57. {
  58. return $this->input;
  59. }
  60. /**
  61. * Retrieves the command output interface
  62. *
  63. * @return OutputInterface
  64. */
  65. public function getOutput()
  66. {
  67. return $this->output;
  68. }
  69. /**
  70. * Retrieves the name of the command being run
  71. *
  72. * @return string
  73. */
  74. public function getCommandName()
  75. {
  76. return $this->commandName;
  77. }
  78. }