Upgrading symfony/event-dispatcher 2 to 3
Breakingv2.8.52 → v3.4.47Breaking1Deprecated2New1
BreakingUpgrade verdict
1 breaking change.
In plain terms
- Events no longer carry the dispatcher or their own name. Listeners receive the dispatcher and event name as arguments instead.
- If you build your own event dispatcher that implements the traceable interface, you should add a reset() method, because leaving it out is now deprecated.
- The ContainerAwareEventDispatcher helper is being retired. Use the regular EventDispatcher and pass closures that create listeners instead.
Must act 3 items need code or config changes
PHP requirement changed in v3.3.7: >=5.3.9 → ^5.5.9|>=7.0.8.
What you must change
Breaking1
Removes Event::setDispatcher(), Event::getDispatcher(), Event::setName() and Event::getName(); dispatcher and event name are now passed to the listener call.
Event::setDispatcher()Event::getDispatcher()Event::setName()Event::getName()Deprecations to plan for
Deprecated2
Deprecates implementing TraceableEventDispatcherInterface without the reset() method.
TraceableEventDispatcherInterfacereset()Deprecates ContainerAwareEventDispatcher in favor of EventDispatcher with closure factories.
ContainerAwareEventDispatcherEventDispatcherAPI changes
Generated by DepDelta from published PHP source. Not mixed with prose notes.
- removed:
method Event.getDispatcher() - removed:
method Event.getName() - removed:
method Event.setDispatcher(EventDispatcherInterface $dispatcher) - removed:
method Event.setName($name) - added:
method EventDispatcherInterface.getListenerPriority($eventName, $listener)
- added:
method TraceableEventDispatcher.reset() - added:
method WrappedListener.getInfo($eventName) - added:
method WrappedListener.getPretty()
- added:
class ExtractingEventDispatcher extends EventDispatcher implements EventSubscriberInterface - added:
method ExtractingEventDispatcher.addListener($eventName, $listener, $priority = …) - added:
method RegisterListenersPass.setHotPathEvents(array $hotPathEvents, $tagName = …) - added:
property ExtractingEventDispatcher.listeners - added:
static method ExtractingEventDispatcher.getSubscribedEvents() - added:
static property ExtractingEventDispatcher.subscriber