DDC-235: Associated Classes Do Not Trigger Event::loadClassMetadata #290

Closed
opened 2026-01-22 12:33:38 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 4, 2010).

Jira issue originally created by user mridgway:

This may or may not be working as intended.

Currently when a class is loaded via association, the loadClassMetadata event is only fired for the original object that was loaded. You can use getClassMetaData to access the lazy loaded class's metadata, but there is no easy way to hook into the loadClassMetadata event for that class.

Example of what I'm trying to do.. I have a class with the following:

/****
 * @Entity
 */
class Block
{
...
    /****
     * @ManyToOne(targetEntity="Content")
     * @JoinColumn(name="content_id", referencedColumnName="id")
     */
    protected $content;
...
}

Content uses Class Table Inheritance to be able to define multiple types of content:

/****
 * @Entity
 * @Table(name="Content")
 * @InheritanceType("JOINED")
 * @DiscriminatorColumn(name="type", type="string")
 * @DiscriminatorMap({"Text"="Text"})
 */
abstract class Content
{
...
}

When Content is lazy loaded from Block, the loadClassMetadata function is never called for Content. In this case I wanted to dynamically add discriminator maps to Content.

As I said before this may be intended since the metadata is loaded with the containing object, but it means I have to make several special cases in loadClassMetadata for every object that maps to Content in order to modify the metadata.

Originally created by @doctrinebot on GitHub (Jan 4, 2010). Jira issue originally created by user mridgway: This may or may not be working as intended. Currently when a class is loaded via association, the loadClassMetadata event is only fired for the original object that was loaded. You can use getClassMetaData to access the lazy loaded class's metadata, but there is no easy way to hook into the loadClassMetadata event for that class. Example of what I'm trying to do.. I have a class with the following: ``` none /**** * @Entity */ class Block { ... /**** * @ManyToOne(targetEntity="Content") * @JoinColumn(name="content_id", referencedColumnName="id") */ protected $content; ... } ``` Content uses Class Table Inheritance to be able to define multiple types of content: ``` none /**** * @Entity * @Table(name="Content") * @InheritanceType("JOINED") * @DiscriminatorColumn(name="type", type="string") * @DiscriminatorMap({"Text"="Text"}) */ abstract class Content { ... } ``` When Content is lazy loaded from Block, the loadClassMetadata function is never called for Content. In this case I wanted to dynamically add discriminator maps to Content. As I said before this may be intended since the metadata is loaded with the containing object, but it means I have to make several special cases in loadClassMetadata for every object that maps to Content in order to modify the metadata.
admin added the Improvement label 2026-01-22 12:33:38 +01:00
admin closed this issue 2026-01-22 12:33:39 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 4, 2010):

Comment created by mridgway:

User error.

@doctrinebot commented on GitHub (Jan 4, 2010): Comment created by mridgway: User error.
Author
Owner

@doctrinebot commented on GitHub (Jan 4, 2010):

Issue was closed with resolution "Invalid"

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

No dependencies set.

Reference: doctrine/archived-orm#290