EventDispatcherInterface.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. */
  26. public function dispatch($eventName, $class, $format, Event $event);
  27. /**
  28. * Adds a listener.
  29. *
  30. * @param string $eventName
  31. * @param callable $callable
  32. * @param string|null $class
  33. * @param string|null $format
  34. */
  35. public function addListener($eventName, $callable, $class = null, $format = null);
  36. /**
  37. * Adds a subscribers.
  38. *
  39. * @param EventSubscriberInterface $subscriber
  40. */
  41. public function addSubscriber(EventSubscriberInterface $subscriber);
  42. }