Event.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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\EventDispatcher;
  12. /**
  13. * The base event class
  14. *
  15. * @author Nils Adermann <naderman@naderman.de>
  16. */
  17. class Event
  18. {
  19. /**
  20. * @var string This event's name
  21. */
  22. protected $name;
  23. /**
  24. * @var boolean Whether the event should not be passed to more listeners
  25. */
  26. private $propagationStopped = false;
  27. /**
  28. * Constructor.
  29. *
  30. * @param string $name The event name
  31. */
  32. public function __construct($name)
  33. {
  34. $this->name = $name;
  35. }
  36. /**
  37. * Returns the event's name.
  38. *
  39. * @return string The event name
  40. */
  41. public function getName()
  42. {
  43. return $this->name;
  44. }
  45. /**
  46. * Checks if stopPropagation has been called
  47. *
  48. * @return boolean Whether propagation has been stopped
  49. */
  50. public function isPropagationStopped()
  51. {
  52. return $this->propagationStopped;
  53. }
  54. /**
  55. * Prevents the event from being passed to further listeners
  56. */
  57. public function stopPropagation()
  58. {
  59. $this->propagationStopped = true;
  60. }
  61. }