Event.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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\EventDispatcher;
  11. /**
  12. * Event is the base class for classes containing event data.
  13. *
  14. * This class contains no event data. It is used by events that do not pass
  15. * state information to an event handler when an event is raised.
  16. *
  17. * You can call the method stopPropagation() to abort the execution of
  18. * further listeners in your event listener.
  19. *
  20. * @link www.doctrine-project.org
  21. * @since 2.0
  22. * @version $Revision: 3938 $
  23. * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
  24. * @author Jonathan Wage <jonwage@gmail.com>
  25. * @author Roman Borschel <roman@code-factory.org>
  26. * @author Bernhard Schussek <bschussek@gmail.com>
  27. *
  28. * @api
  29. */
  30. class Event
  31. {
  32. /**
  33. * @var Boolean Whether no further event listeners should be triggered
  34. */
  35. private $propagationStopped = false;
  36. /**
  37. * Returns whether further event listeners should be triggered.
  38. *
  39. * @see Event::stopPropagation
  40. * @return Boolean Whether propagation was already stopped for this event.
  41. *
  42. * @api
  43. */
  44. public function isPropagationStopped()
  45. {
  46. return $this->propagationStopped;
  47. }
  48. /**
  49. * Stops the propagation of the event to further event listeners.
  50. *
  51. * If multiple event listeners are connected to the same event, no
  52. * further event listener will be triggered once any trigger calls
  53. * stopPropagation().
  54. *
  55. * @api
  56. */
  57. public function stopPropagation()
  58. {
  59. $this->propagationStopped = true;
  60. }
  61. }