Use custom lifecycle event classes for the soft-deleteable lifecycle events #2725
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ref: #2708
In ORM 3.0, the
Doctrine\ORM\Event\LifecycleEventArgs
class is removed and the ORM's lifecycle event classes directly extendDoctrine\Persistence\Event\LifecycleEventArgs
. This makes the ORM's implementation ofGedmo\Mapping\Event\AdapterInterface::createLifecycleEventArgsInstance()
unusable on 3.0 since it no longer has its own lifecycle event args subclass.Currently, the only use of this method inside the package is for the soft-deleteable extension's events.
My solution to this ORM deprecation comes with a minor B/C break; instead of dispatching the events with manager-specific event classes, the events are now dispatched with custom subclasses of
Doctrine\Persistence\Event\LifecycleEventArgs
for both supported managers. The B/C break here is that event listeners which typehint againstDoctrine\ODM\MongoDB\Event\LifecycleEventArgs
andDoctrine\ORM\Event\LifecycleEventArgs
will be broken because the class inheritance chain is changed. This would also deprecate the implementations ofGedmo\Mapping\Event\AdapterInterface::createLifecycleEventArgsInstance()
(currently soft-required through@method
annotations).There is an alternative solution that only has a B/C break for ORM users; changing this method to always use the
Doctrine\Persistence\Event\LifecycleEventArgs
class while the ODM adapter still uses its manager-specific subclass.But because of the ORM 3.0 class removal, there will have to be a B/C break at some point, and I figured this would be the best alternative going forward.