doctrine/doctrine2 — pull request #221 by comfortablynumb (2011-12-16 23:45:10+00:00)
Title: [Inheritance] Joined: Default discriminator map

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.

Two things come to mind though:

1) Is there any special case this would cause problems that I don't know of?
2) If not then, Is there a better place to put this code so I don't have to implement it in all drivers? I've been looking at the ClassMetadataFactory class but I didn't find a place to put this code because it seems it's too late to calculate the discriminator map at the time this class is used. So, in case there is no other place, where should I refactor the logic? It feels uncomfortable to create a class just to put this simple logic on, but as drivers don't inherit from any class, I don't see another option.

Thanks!