Open doctrinebot opened 12 years ago
Comment created by deatheriam:
We need this feature too. Why is this ticket in a limbo? Someone please add a comment whether this will be fixed.
Comment created by @ocramius:
[~deatheriam] you can open a pull request with a test and suggested improvement for this at https://github.com/doctrine/doctrine2
It seems that nobody want to add this, but it's really something that is missing. I'm going to do a pull request for this, if it would be possible to be added to latest version it would be a great help.
@fghamsary did you give it a try? It seems that it's still not possible to override targetEntity
.
I can confirm that it's not possible, and I found a work around by not using targetEntity, because it was not working as it should!
@fghamsary could you share the workaround?
I think him refers to https://www.doctrine-project.org/projects/doctrine-orm/en/3.2/cookbook/resolve-target-entity-listener.html Please @fghamsary ask me if you need a wider answer with samples.
@beberlei I think this issue could be considered as ready for closure, couldn't?
@fghamsary could you share the workaround?
To be honest, I don't remember what I did to resolve the problem, I think I didn't specified the targetEntity on the abstract class, and duplicated the field two times on each children. But it has been a while, so I really don't know what I did. I'll try to find on our code base the workaround that I used, and if I find it, I'll let you know.
Jira issue originally created by user cro:
While associating object to an descriminated table I wasn't enable to fix the entityTarget (only one can be set in entity annotation).
It could be resolve by adding the possibility to override 'targetEntity' value in Doctrine\ORM\Mapping\ClassMetadataInfo::ClassMetadataInfo().
Such as : {quote} if (isset($overrideMapping['targetEntity'])) { $mapping['targetEntity'] = $overrideMapping['targetEntity']; } {quote}
That would need to add a control on the new targetEntity in Doctrine\ORM\Mapping\ClassMetadataInfo::_validateAndCompleteAssociationMapping().
Such as : {quote} if ( ! ClassLoader::classExists($mapping['targetEntity']) ) { throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']); } {quote}
cro.