|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Contracts\EventDispatcher; |
| 13 | + |
| 14 | +use Psr\EventDispatcher\StoppableEventInterface; |
| 15 | + |
| 16 | +if (interface_exists(StoppableEventInterface::class)) { |
| 17 | + /** |
| 18 | + * Event is the base class for classes containing event data. |
| 19 | + * |
| 20 | + * This class contains no event data. It is used by events that do not pass |
| 21 | + * state information to an event handler when an event is raised. |
| 22 | + * |
| 23 | + * You can call the method stopPropagation() to abort the execution of |
| 24 | + * further listeners in your event listener. |
| 25 | + * |
| 26 | + * @author Guilherme Blanco <guilhermeblanco@hotmail.com> |
| 27 | + * @author Jonathan Wage <jonwage@gmail.com> |
| 28 | + * @author Roman Borschel <roman@code-factory.org> |
| 29 | + * @author Bernhard Schussek <bschussek@gmail.com> |
| 30 | + * @author Nicolas Grekas <p@tchwork.com> |
| 31 | + */ |
| 32 | + class Event implements StoppableEventInterface |
| 33 | + { |
| 34 | + private $propagationStopped = false; |
| 35 | + |
| 36 | + /** |
| 37 | + * Returns whether further event listeners should be triggered. |
| 38 | + */ |
| 39 | + public function isPropagationStopped(): bool |
| 40 | + { |
| 41 | + return $this->propagationStopped; |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Stops the propagation of the event to further event listeners. |
| 46 | + * |
| 47 | + * If multiple event listeners are connected to the same event, no |
| 48 | + * further event listener will be triggered once any trigger calls |
| 49 | + * stopPropagation(). |
| 50 | + */ |
| 51 | + public function stopPropagation(): void |
| 52 | + { |
| 53 | + $this->propagationStopped = true; |
| 54 | + } |
| 55 | + } |
| 56 | +} else { |
| 57 | + /** |
| 58 | + * Event is the base class for classes containing event data. |
| 59 | + * |
| 60 | + * This class contains no event data. It is used by events that do not pass |
| 61 | + * state information to an event handler when an event is raised. |
| 62 | + * |
| 63 | + * You can call the method stopPropagation() to abort the execution of |
| 64 | + * further listeners in your event listener. |
| 65 | + * |
| 66 | + * @author Guilherme Blanco <guilhermeblanco@hotmail.com> |
| 67 | + * @author Jonathan Wage <jonwage@gmail.com> |
| 68 | + * @author Roman Borschel <roman@code-factory.org> |
| 69 | + * @author Bernhard Schussek <bschussek@gmail.com> |
| 70 | + * @author Nicolas Grekas <p@tchwork.com> |
| 71 | + */ |
| 72 | + class Event |
| 73 | + { |
| 74 | + private $propagationStopped = false; |
| 75 | + |
| 76 | + /** |
| 77 | + * Returns whether further event listeners should be triggered. |
| 78 | + */ |
| 79 | + public function isPropagationStopped(): bool |
| 80 | + { |
| 81 | + return $this->propagationStopped; |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Stops the propagation of the event to further event listeners. |
| 86 | + * |
| 87 | + * If multiple event listeners are connected to the same event, no |
| 88 | + * further event listener will be triggered once any trigger calls |
| 89 | + * stopPropagation(). |
| 90 | + */ |
| 91 | + public function stopPropagation(): void |
| 92 | + { |
| 93 | + $this->propagationStopped = true; |
| 94 | + } |
| 95 | + } |
| 96 | +} |
0 commit comments