Açıklama Yok

EventDispatcherInterface.php 2.7KB

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