Bez popisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EventDispatcherInterface.php 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 int $priority The higher this value, the earlier an event
  25. * listener will be triggered in the chain (defaults to 0)
  26. */
  27. public function addListener(string $eventName, callable $listener, int $priority = 0);
  28. /**
  29. * Adds an event subscriber.
  30. *
  31. * The subscriber is asked for all the events it is
  32. * interested in and added as a listener for these events.
  33. */
  34. public function addSubscriber(EventSubscriberInterface $subscriber);
  35. /**
  36. * Removes an event listener from the specified events.
  37. */
  38. public function removeListener(string $eventName, callable $listener);
  39. public function removeSubscriber(EventSubscriberInterface $subscriber);
  40. /**
  41. * Gets the listeners of a specific event or all listeners sorted by descending priority.
  42. *
  43. * @return array<callable[]|callable>
  44. */
  45. public function getListeners(?string $eventName = null);
  46. /**
  47. * Gets the listener priority for a specific event.
  48. *
  49. * Returns null if the event or the listener does not exist.
  50. *
  51. * @return int|null
  52. */
  53. public function getListenerPriority(string $eventName, callable $listener);
  54. /**
  55. * Checks whether an event has any registered listeners.
  56. *
  57. * @return bool
  58. */
  59. public function hasListeners(?string $eventName = null);
  60. }