DDC-1542: GH-221: [Inheritance] Joined: Default discriminator map #1936

Closed
opened 2026-01-22 13:32:27 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 16, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user @beberlei:

Pull-Request was automatically synchronized: https://github.com/doctrine/doctrine2/pull/221

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!

Originally created by @doctrinebot on GitHub (Dec 16, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user @beberlei: Pull-Request was automatically synchronized: https://github.com/doctrine/doctrine2/pull/221 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!
admin added the Improvement label 2026-01-22 13:32:27 +01:00
admin closed this issue 2026-01-22 13:32:27 +01:00
Author
Owner

@doctrinebot commented on GitHub (Dec 28, 2011):

Comment created by @beberlei:

Mark as improvement and schedule for 2.3

@doctrinebot commented on GitHub (Dec 28, 2011): Comment created by @beberlei: Mark as improvement and schedule for 2.3
Author
Owner

@doctrinebot commented on GitHub (Mar 22, 2012):

Comment created by @beberlei:

A related Github Pull-Request [GH-221] was
https://github.com/doctrine/doctrine2/pull/221

@doctrinebot commented on GitHub (Mar 22, 2012): Comment created by @beberlei: A related Github Pull-Request [GH-221] was https://github.com/doctrine/doctrine2/pull/221
Author
Owner

@doctrinebot commented on GitHub (May 4, 2012):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (May 4, 2012): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1936