mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
EntityListenerPass unaware of ResolveTargetEntityListener::$resolveTargetEntities #7178
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @BreyndotEchse on GitHub (Jul 10, 2023).
Feature Request
Summary
The
Doctrine\ORM\Tools\AttachEntityListenersListenerdoes not attach any entity listeners targeting interfaces or abstract classes, because it is not aware of theDoctrine\ORM\Tools\ResolveTargetEntityListener::$resolveTargetEntitiesused to resolve and load ClassMetadata of these interfaces or classes.Dysfunctional config example:
So what I would like to do is:
ResolveTargetEntityListener::$resolveTargetEntitiesto separate service: TargetEntityResolverResolveTargetEntityListener::addResolveTargetEntity()calls toTargetEntityResolver::addResolveTargetEntity()@deprecateddoc toResolveTargetEntityListener::addResolveTargetEntity()Any concerns?
(Copied from https://github.com/doctrine/DoctrineBundle/issues/1683)
@BreyndotEchse commented on GitHub (Jul 10, 2023):
@stof https://github.com/doctrine/DoctrineBundle/issues/1683#issuecomment-1625735263
Doctrine\ORM\Mapping\ClassMetadataFactory::doLoadMetadataemits the "loadClassMetadata" event. AFAICS this method won't be called if metadata of this class is already cached inDoctrine\Persistence\Mapping\AbstractClassMetadataFactory::$loadedMetadata. So the performance impact of this change would be (almost) zero becauseDoctrine\ORM\Tools\AttachEntityListenersListeneris only called once per entity class at most.Let's say we have an entity, that depends on external services to serialize/unserialize specific data. Lifecycle callbacks don't support additional arguments, so you have to rely on EntityListeners. Lets's say we have something like this:
When I then create an entity in another bundle that implements the "MyEntityInterface" interface, would it be on the bundle's part to attache the entity listener? Does not feel right because the interface gives the impression it was already attached by the bundle that it is part of.