annotate vendor/symfony/event-dispatcher/EventDispatcherInterface.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /*
Chris@0 4 * This file is part of the Symfony package.
Chris@0 5 *
Chris@0 6 * (c) Fabien Potencier <fabien@symfony.com>
Chris@0 7 *
Chris@0 8 * For the full copyright and license information, please view the LICENSE
Chris@0 9 * file that was distributed with this source code.
Chris@0 10 */
Chris@0 11
Chris@0 12 namespace Symfony\Component\EventDispatcher;
Chris@0 13
Chris@0 14 /**
Chris@0 15 * The EventDispatcherInterface is the central point of Symfony's event listener system.
Chris@0 16 * Listeners are registered on the manager and events are dispatched through the
Chris@0 17 * manager.
Chris@0 18 *
Chris@0 19 * @author Bernhard Schussek <bschussek@gmail.com>
Chris@0 20 */
Chris@0 21 interface EventDispatcherInterface
Chris@0 22 {
Chris@0 23 /**
Chris@0 24 * Dispatches an event to all registered listeners.
Chris@0 25 *
Chris@17 26 * @param string $eventName The name of the event to dispatch. The name of
Chris@17 27 * the event is the name of the method that is
Chris@17 28 * invoked on listeners.
Chris@17 29 * @param Event|null $event The event to pass to the event handlers/listeners
Chris@17 30 * If not supplied, an empty Event instance is created
Chris@0 31 *
Chris@0 32 * @return Event
Chris@0 33 */
Chris@0 34 public function dispatch($eventName, Event $event = null);
Chris@0 35
Chris@0 36 /**
Chris@0 37 * Adds an event listener that listens on the specified events.
Chris@0 38 *
Chris@0 39 * @param string $eventName The event to listen on
Chris@0 40 * @param callable $listener The listener
Chris@0 41 * @param int $priority The higher this value, the earlier an event
Chris@0 42 * listener will be triggered in the chain (defaults to 0)
Chris@0 43 */
Chris@0 44 public function addListener($eventName, $listener, $priority = 0);
Chris@0 45
Chris@0 46 /**
Chris@0 47 * Adds an event subscriber.
Chris@0 48 *
Chris@17 49 * The subscriber is asked for all the events it is
Chris@0 50 * interested in and added as a listener for these events.
Chris@0 51 */
Chris@0 52 public function addSubscriber(EventSubscriberInterface $subscriber);
Chris@0 53
Chris@0 54 /**
Chris@0 55 * Removes an event listener from the specified events.
Chris@0 56 *
Chris@0 57 * @param string $eventName The event to remove a listener from
Chris@0 58 * @param callable $listener The listener to remove
Chris@0 59 */
Chris@0 60 public function removeListener($eventName, $listener);
Chris@0 61
Chris@0 62 public function removeSubscriber(EventSubscriberInterface $subscriber);
Chris@0 63
Chris@0 64 /**
Chris@0 65 * Gets the listeners of a specific event or all listeners sorted by descending priority.
Chris@0 66 *
Chris@17 67 * @param string|null $eventName The name of the event
Chris@0 68 *
Chris@0 69 * @return array The event listeners for the specified event, or all event listeners by event name
Chris@0 70 */
Chris@0 71 public function getListeners($eventName = null);
Chris@0 72
Chris@0 73 /**
Chris@0 74 * Gets the listener priority for a specific event.
Chris@0 75 *
Chris@0 76 * Returns null if the event or the listener does not exist.
Chris@0 77 *
Chris@0 78 * @param string $eventName The name of the event
Chris@0 79 * @param callable $listener The listener
Chris@0 80 *
Chris@0 81 * @return int|null The event listener priority
Chris@0 82 */
Chris@0 83 public function getListenerPriority($eventName, $listener);
Chris@0 84
Chris@0 85 /**
Chris@0 86 * Checks whether an event has any registered listeners.
Chris@0 87 *
Chris@17 88 * @param string|null $eventName The name of the event
Chris@0 89 *
Chris@0 90 * @return bool true if the specified event has any listeners, false otherwise
Chris@0 91 */
Chris@0 92 public function hasListeners($eventName = null);
Chris@0 93 }