0
0

Event.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\Contracts\EventDispatcher;
  11. use Psr\EventDispatcher\StoppableEventInterface;
  12. /**
  13. * Event is the base class for classes containing event data.
  14. *
  15. * This class contains no event data. It is used by events that do not pass
  16. * state information to an event handler when an event is raised.
  17. *
  18. * You can call the method stopPropagation() to abort the execution of
  19. * further listeners in your event listener.
  20. *
  21. * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
  22. * @author Jonathan Wage <jonwage@gmail.com>
  23. * @author Roman Borschel <roman@code-factory.org>
  24. * @author Bernhard Schussek <bschussek@gmail.com>
  25. * @author Nicolas Grekas <p@tchwork.com>
  26. */
  27. class Event implements StoppableEventInterface
  28. {
  29. private $propagationStopped = false;
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function isPropagationStopped(): bool
  34. {
  35. return $this->propagationStopped;
  36. }
  37. /**
  38. * Stops the propagation of the event to further event listeners.
  39. *
  40. * If multiple event listeners are connected to the same event, no
  41. * further event listener will be triggered once any trigger calls
  42. * stopPropagation().
  43. */
  44. public function stopPropagation(): void
  45. {
  46. $this->propagationStopped = true;
  47. }
  48. }