EventDispatcherInterface.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.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. * EventDispatcherInterface describes an event dispatcher class.
  13. *
  14. * @see http://developer.apple.com/documentation/Cocoa/Conceptual/Notifications/index.html Apple's Cocoa framework
  15. *
  16. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  17. */
  18. interface EventDispatcherInterface
  19. {
  20. /**
  21. * Connects a listener to a given event name.
  22. *
  23. * Listeners with a higher priority are executed first.
  24. *
  25. * @param string $name An event name
  26. * @param mixed $listener A PHP callable
  27. * @param integer $priority The priority (between -10 and 10 -- defaults to 0)
  28. */
  29. function connect($name, $listener, $priority = 0);
  30. /**
  31. * Disconnects one, or all listeners for the given event name.
  32. *
  33. * @param string $name An event name
  34. * @param mixed|null $listener The listener to remove, or null to remove all
  35. *
  36. * @return void
  37. */
  38. function disconnect($name, $listener = null);
  39. /**
  40. * Notifies all listeners of a given event.
  41. *
  42. * @param EventInterface $event An EventInterface instance
  43. *
  44. * @return EventInterface The EventInterface instance
  45. */
  46. function notify(EventInterface $event);
  47. /**
  48. * Notifies all listeners of a given event until one returns a non null value.
  49. *
  50. * @param EventInterface $event An EventInterface instance
  51. *
  52. * @return EventInterface The EventInterface instance
  53. */
  54. function notifyUntil(EventInterface $event);
  55. /**
  56. * Filters a value by calling all listeners of a given event.
  57. *
  58. * @param EventInterface $event An EventInterface instance
  59. * @param mixed $value The value to be filtered
  60. *
  61. * @return EventInterface The EventInterface instance
  62. */
  63. function filter(EventInterface $event, $value);
  64. /**
  65. * Returns true if the given event name has some listeners.
  66. *
  67. * @param string $name The event name
  68. *
  69. * @return Boolean true if some listeners are connected, false otherwise
  70. */
  71. function hasListeners($name);
  72. /**
  73. * Returns all listeners associated with a given event name.
  74. *
  75. * @param string $name The event name
  76. *
  77. * @return array An array of listeners
  78. */
  79. function getListeners($name);
  80. }