mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #221] [CLOSED] [Inheritance] Joined: Default discriminator map #7877
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?
📋 Pull Request Information
Original PR: https://github.com/doctrine/orm/pull/221
Author: @comfortablynumb
Created: 12/16/2011
Status: ❌ Closed
Base:
master← Head:default-discriminator-map📝 Commits (10+)
d7042abMerge branch 'master', remote branch 'upstream/master'bf9024bMerge remote branch 'upstream/master'6d5f15eMerge remote branch 'upstream/master'e61d959[Inheritance] Joined type: Added default discriminator map (only annotations yet)6923fe9Some minor CS fixes.842f87c[Inheritance] Joined: Changed implementation of the default discriminator map calculationb4eb7a5Optimized a little bit the generation of the default discriminator map80d088fFixed test and other minor issuesa76b0a5Some refactor in ClassMetadataFactory2a54975Added more tests📊 Changes
5 files changed (+165 additions, -4 deletions)
View changed files
📝
lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php(+90 -4)➕
tests/Doctrine/Tests/Models/JoinedInheritanceType/AnotherChildClass.php(+10 -0)➕
tests/Doctrine/Tests/Models/JoinedInheritanceType/ChildClass.php(+10 -0)➕
tests/Doctrine/Tests/Models/JoinedInheritanceType/RootClass.php(+16 -0)📝
tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php(+39 -0)📄 Description
Hi all,
I know this topic was discussed a lot of times, but I wanted to give it a try anyway.
I want the discriminator map to be configured dynamically by doctrine instead of having to manually configure it myself. So I've digged into the code and the only place I've found (yet) to put the necessary code to make this happen is in the Drivers, just when they're loading the mapping information. So far, I've put a very simple piece of code in the AnnotationDriver to give it a try and I wrote a test for it. But before going on I wanted to ask you if it looks ok for you.
I've tested it in an application I'm working on and, so far, it works.
So, in a brief, what this does is, if you have a class which is the root of a class table inheritance tree (JOINED type), you can let doctrine configure the DiscriminatorMap for you, filling it with all the subclasses of the root class. If, for some reason, the user needs to configure it by himself, then he can do it. If the DiscriminatorMap is set, Doctrine doesn't generate it.
I think this is useful. It's error prone to configure it manually every time a new class is added to the inheritance tree. And this is better in cases where you can't know which entities are present and which aren't (for example, think about pluggable modules in a modular application). There's a way to do it (although I didn't try it. Just read about it), but this is simpler and works out of the box.
Two things come to mind though:
I'll wait for your comments to continue with this.
Thanks!
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.