JMSSerializerBundle icon indicating copy to clipboard operation
JMSSerializerBundle copied to clipboard

Single table inheritance

Open jbouzekri opened this issue 11 years ago • 3 comments

Hi,

I don't know if there is a bug or if I do it the wrong way or if this is impossible.

I use single table inheritance in doctrine and I wanted to change the way JMS serializes the entity according to the entity class.

In my single table inheritance, I have a type column which is used to map the discriminator value.

My parent entity is BundleNamespace\Entity\Question. When type is single_choice, my entity is BundleNamespace\Entity\Question\SingleChoiceQuestion. When type is multiples_choice, my entity is BundleNamespace\Entity\Question\MultipleChoiceQuestion.

I configured jms in config.yml

jms_serializer:
    metadata:
        directories:
            exam:
                namespace_prefix: "BundleNamespace"
                path: "@BundleNamespace/Resources/config/serializer"

However when I create a yaml serializer file specific for each child entity, it does not seem to apply the right configuration file :

  • @BundleNamespace/Resources/config/serializer/Entity.Question.SingleChoiceQuestion.yml
  • @BundleNamespace/Resources/config/serializer/Entity.Question.MultipleChoiceQuestion.yml

Thans in advance

Best regards

jbouzekri avatar Aug 23 '14 21:08 jbouzekri

+1

Serialize rules in child entities on Single Table inheritance are ingored.

diimpp avatar Feb 17 '15 08:02 diimpp

+1 Is anyone else trying to serialize/deserialize an entity that uses single table inheritance?

jfcorsini avatar Apr 05 '18 13:04 jfcorsini

Hey guys! I want to exclude discriminator field. Did anyone figure out how to do it??

AbdallahAbdedaiem avatar Mar 11 '20 14:03 AbdallahAbdedaiem