|
| 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\EventDispatcherInterface as PsrEventDispatcherInterface; |
| 15 | + |
| 16 | +if (interface_exists(PsrEventDispatcherInterface::class)) { |
| 17 | + /** |
| 18 | + * Allows providing hooks on domain-specific lifecycles by dispatching events. |
| 19 | + */ |
| 20 | + interface EventDispatcherInterface extends PsrEventDispatcherInterface |
| 21 | + { |
| 22 | + /** |
| 23 | + * Dispatches an event to all registered listeners. |
| 24 | + * |
| 25 | + * For BC with Symfony 4, the $eventName argument is not declared explicitly on the |
| 26 | + * signature of the method. Implementations that are not bound by this BC contraint |
| 27 | + * MUST declare it explicitly, as allowed by PHP. |
| 28 | + * |
| 29 | + * @param object $event The event to pass to the event handlers/listeners |
| 30 | + * @param string|null $eventName The name of the event to dispatch. If not supplied, |
| 31 | + * the class of $event should be used instead. |
| 32 | + * |
| 33 | + * @return object The passed $event MUST be returned |
| 34 | + */ |
| 35 | + public function dispatch($event/*, string $eventName = null*/); |
| 36 | + } |
| 37 | +} else { |
| 38 | + /** |
| 39 | + * Allows providing hooks on domain-specific lifecycles by dispatching events. |
| 40 | + */ |
| 41 | + interface EventDispatcherInterface |
| 42 | + { |
| 43 | + /** |
| 44 | + * Dispatches an event to all registered listeners. |
| 45 | + * |
| 46 | + * For BC with Symfony 4, the $eventName argument is not declared explicitly on the |
| 47 | + * signature of the method. Implementations that are not bound by this BC contraint |
| 48 | + * MUST declare it explicitly, as allowed by PHP. |
| 49 | + * |
| 50 | + * @param object $event The event to pass to the event handlers/listeners |
| 51 | + * @param string|null $eventName The name of the event to dispatch. If not supplied, |
| 52 | + * the class of $event should be used instead. |
| 53 | + * |
| 54 | + * @return object The passed $event MUST be returned |
| 55 | + */ |
| 56 | + public function dispatch($event/*, string $eventName = null*/); |
| 57 | + } |
| 58 | +} |
0 commit comments