You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an abstract parent entity with several sub entities. The discriminator column is called "type". No matter what, when serializing these sub entities, the "type" column is added to the output, even though it isn't a property that I can access on the entity, thus I can't get rid of it.
I've solved through a rather roundabout method of overriding GenericSerializationVisitor (via overriding JsonSerializationVisitor) and adding a method "removeData".
public function removeData($key){
if (isset($this->data[$key])) unset($this->data[$key]);
}
Then, I have a listener function set up on post_serialize of my sub entities, in which I call
public function postSerializeSubEntity(ObjectEvent $event)
{
$event->getVisitor()->removeData('type');
}
Hope this is helpful to someone else. If there is a better way of solving this issue that I missed please let me know!
The text was updated successfully, but these errors were encountered:
I have an abstract parent entity with several sub entities. The discriminator column is called "type". No matter what, when serializing these sub entities, the "type" column is added to the output, even though it isn't a property that I can access on the entity, thus I can't get rid of it.
I've solved through a rather roundabout method of overriding GenericSerializationVisitor (via overriding JsonSerializationVisitor) and adding a method "removeData".
Then, I have a listener function set up on post_serialize of my sub entities, in which I call
Hope this is helpful to someone else. If there is a better way of solving this issue that I missed please let me know!
The text was updated successfully, but these errors were encountered: