菜谱项目

Event.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
  21. * @author Jonathan Wage <jonwage@gmail.com>
  22. * @author Roman Borschel <roman@code-factory.org>
  23. * @author Bernhard Schussek <bschussek@gmail.com>
  24. */
  25. class Event
  26. {
  27. /**
  28. * @var bool Whether no further event listeners should be triggered
  29. */
  30. private $propagationStopped = false;
  31. /**
  32. * Returns whether further event listeners should be triggered.
  33. *
  34. * @see Event::stopPropagation()
  35. *
  36. * @return bool Whether propagation was already stopped for this event
  37. */
  38. public function isPropagationStopped()
  39. {
  40. return $this->propagationStopped;
  41. }
  42. /**
  43. * Stops the propagation of the event to further event listeners.
  44. *
  45. * If multiple event listeners are connected to the same event, no
  46. * further event listener will be triggered once any trigger calls
  47. * stopPropagation().
  48. */
  49. public function stopPropagation()
  50. {
  51. $this->propagationStopped = true;
  52. }
  53. }