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.

49 lines
1.7 KiB

3 years ago
  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. * An EventSubscriber knows itself what events it is interested in.
  13. * If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes
  14. * {@link getSubscribedEvents} and registers the subscriber as a listener for all
  15. * returned events.
  16. *
  17. * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
  18. * @author Jonathan Wage <jonwage@gmail.com>
  19. * @author Roman Borschel <roman@code-factory.org>
  20. * @author Bernhard Schussek <bschussek@gmail.com>
  21. */
  22. interface EventSubscriberInterface
  23. {
  24. /**
  25. * Returns an array of event names this subscriber wants to listen to.
  26. *
  27. * The array keys are event names and the value can be:
  28. *
  29. * * The method name to call (priority defaults to 0)
  30. * * An array composed of the method name to call and the priority
  31. * * An array of arrays composed of the method names to call and respective
  32. * priorities, or 0 if unset
  33. *
  34. * For instance:
  35. *
  36. * * ['eventName' => 'methodName']
  37. * * ['eventName' => ['methodName', $priority]]
  38. * * ['eventName' => [['methodName1', $priority], ['methodName2']]]
  39. *
  40. * The code must not depend on runtime state as it will only be called at compile time.
  41. * All logic depending on runtime state must be put into the individual methods handling the events.
  42. *
  43. * @return array The event names to listen to
  44. */
  45. public static function getSubscribedEvents();
  46. }