ju_
ju_

Reputation: 566

How to extend symfony entity in bundle

Is there a way I can extend a symfony entity in another bundle using @DiscriminatorMap without having to specify it beforehand?

BundleA

BundleB

Upvotes: 0

Views: 176

Answers (1)

Arleigh Hix
Arleigh Hix

Reputation: 10877

You can try letting doctrine auto-generate the discriminator map.
From the last bullet point in this section of the docs:

If no discriminator map is provided, then the map is generated automatically. The automatically generated discriminator map contains the lowercase short name of each class as key. So you would:

  1. Omit the @DiscriminatorMap declaration in BundleA.
  2. Extend the entity as normal in BundleB (making sure the short name of each class is unique).
  3. Update the database schema.

EDIT
As pointed out by ju_ in the comments, this solution will apparently not work with Doctrine ORM 3.0, but should still be valid for versions 2.5 - 2.7

Upvotes: 1

Related Questions