EventDispatcherInterface.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace JMS\SerializerBundle\Serializer\EventDispatcher;
  3. interface EventDispatcherInterface
  4. {
  5. /**
  6. * Returns whether there are listeners.
  7. *
  8. * @param string $eventName
  9. * @param string $class
  10. * @param string $format
  11. *
  12. * @return boolean
  13. */
  14. public function hasListeners($eventName, $class, $format);
  15. /**
  16. * Dispatches an event.
  17. *
  18. * The listeners/subscribers are called in the same order in which they
  19. * were added to the dispatcher.
  20. *
  21. * @param string $eventName
  22. * @param string $class
  23. * @param string $format
  24. * @param Event $event
  25. * @return void
  26. */
  27. public function dispatch($eventName, $class, $format, Event $event);
  28. /**
  29. * Adds a listener.
  30. *
  31. * @param string $eventName
  32. * @param callable $callable
  33. * @param string|null $class
  34. * @param string|null $format
  35. * @return void
  36. */
  37. public function addListener($eventName, $callable, $class = null, $format = null);
  38. /**
  39. * Adds a subscribers.
  40. *
  41. * @param EventSubscriberInterface $subscriber
  42. * @return void
  43. */
  44. public function addSubscriber(EventSubscriberInterface $subscriber);
  45. }