Drupal investigation

EventDispatcherInterface.php 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. * The EventDispatcherInterface is the central point of Symfony's event listener system.
  13. * Listeners are registered on the manager and events are dispatched through the
  14. * manager.
  15. *
  16. * @author Bernhard Schussek <bschussek@gmail.com>
  17. */
  18. interface EventDispatcherInterface
  19. {
  20. /**
  21. * Dispatches an event to all registered listeners.
  22. *
  23. * @param string $eventName The name of the event to dispatch. The name of
  24. * the event is the name of the method that is
  25. * invoked on listeners.
  26. * @param Event $event The event to pass to the event handlers/listeners
  27. * If not supplied, an empty Event instance is created.
  28. *
  29. * @return Event
  30. */
  31. public function dispatch($eventName, Event $event = null);
  32. /**
  33. * Adds an event listener that listens on the specified events.
  34. *
  35. * @param string $eventName The event to listen on
  36. * @param callable $listener The listener
  37. * @param int $priority The higher this value, the earlier an event
  38. * listener will be triggered in the chain (defaults to 0)
  39. */
  40. public function addListener($eventName, $listener, $priority = 0);
  41. /**
  42. * Adds an event subscriber.
  43. *
  44. * The subscriber is asked for all the events he is
  45. * interested in and added as a listener for these events.
  46. *
  47. * @param EventSubscriberInterface $subscriber The subscriber
  48. */
  49. public function addSubscriber(EventSubscriberInterface $subscriber);
  50. /**
  51. * Removes an event listener from the specified events.
  52. *
  53. * @param string $eventName The event to remove a listener from
  54. * @param callable $listener The listener to remove
  55. */
  56. public function removeListener($eventName, $listener);
  57. /**
  58. * Removes an event subscriber.
  59. *
  60. * @param EventSubscriberInterface $subscriber The subscriber
  61. */
  62. public function removeSubscriber(EventSubscriberInterface $subscriber);
  63. /**
  64. * Gets the listeners of a specific event or all listeners sorted by descending priority.
  65. *
  66. * @param string $eventName The name of the event
  67. *
  68. * @return array The event listeners for the specified event, or all event listeners by event name
  69. */
  70. public function getListeners($eventName = null);
  71. /**
  72. * Checks whether an event has any registered listeners.
  73. *
  74. * @param string $eventName The name of the event
  75. *
  76. * @return bool true if the specified event has any listeners, false otherwise
  77. */
  78. public function hasListeners($eventName = null);
  79. }