Event Dispatcher Flashcards

1
Q

What OOP patterns does the event-dispatcher component implement?

A

Mediator and observer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What methods does Symfony\Component\EventDispatcher\EventDispatcherInterface define?

A

addListener(string $eventName, $listener, int $priority = 0);
addSubscriber(EventSubscriberInterface $subscriber);
removeListener(string $eventName, $listener);
removeSubscriber(EventSubscriberInterface $subscriber);
getListeners(string $eventName = null);
getListenerPriority(string $eventName, $listener);
hasListeners(string $eventName = null);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What tags are used to register event listeners and event subscribers via the DIC?

A

kernel. event_listener

kernel. event_subscriber

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the difference between an event listener and event subscriber?

A
Event listener is a PHP callable that is triggered when a specific event is fired.
Event subscriber is a class that implements Symfony\Component\EventDispatcher\EventSubscriberInterface and defines any number of possible methods to be triggered by any number of possible events.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly