mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Dynamic targetEntity #5056
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 @deviprsd on GitHub (Mar 19, 2016).
Originally assigned to: @Ocramius on GitHub.
I want dynamic entity mapping on one entity which will be used by other entities. For example, I have a File entity, which will store mime type, mapping key, name etc, also an entity_id which will contain the id to the entity it belongs to. The mapping key will determine the class as this file entity will be ManyToMany. So the targetEntity for File entity isn't fixed. How to achieve that?
@Ma27 commented on GitHub (Mar 20, 2016):
For a dynamic resolve of target entities the
ResolveTargetEntityListenercan be used:http://docs.doctrine-project.org/en/latest/cookbook/resolve-target-entity-listener.html
@deviprsd commented on GitHub (Mar 20, 2016):
Yeah but that only resolves one entity, I want to resolve multiple entities with one mapping. Is that possible?
@Ocramius commented on GitHub (Mar 20, 2016):
You can resolve to a different entity before booting the ORM, each time to an entity of your choice. Swapping the resolved target entity at runtime is not supported.
@deviprsd commented on GitHub (Mar 20, 2016):
I wanted during runtime, so never mind.
@deviprsd commented on GitHub (Mar 20, 2016):
Also, I posted the same question in stack overflow, but more detailed.
http://stackoverflow.com/questions/36104055/dynamic-target-entity-doctrine-2-and-symfony-2
Can you answer with respective to this?
@inceddy commented on GitHub (May 24, 2017):
Did you make any progress on this? I stumbled across this while thinking about attaching "Comment" entities to several other entities with "CommentableInterface".