JMSSerializerBundle: The discriminator field name \"discriminator\" of the base-class "..." conflicts with a regular property of the sub-class "...".
I have came across an issue with single table inheritance and serialisation - I get the above error unless I comment out the following code in ClassMetadata.php, after which it works as expected:
if (isset($this->propertyMetadata[$this->discriminatorFieldName])
&& ! $this->propertyMetadata[$this->discriminatorFieldName] instanceof StaticPropertyMetadata) {
throw new \LogicException(sprintf(
'The discriminator field name "%s" of the base-class "%s" conflicts with a regular property of the sub-class "%s".',
$this->discriminatorFieldName,
$this->discriminatorBaseClass,
$this->name
));
}
I think the exception is thrown because it’s checking if the subclass has a property with the name of the discriminator field, which it has to as it subclasses the base-class which defines the field - unless I’m misunderstanding?
About this issue
- Original URL
- State: open
- Created 11 years ago
- Comments: 24
Commits related to this issue
- Merge pull request #299 from goetas/patch-2 Added xml_root_namespace on YAML reference — committed to jorns/JMSSerializerBundle by schmittjoh 10 years ago
Recently I faced same error. What I did is just remove discriminator field from class.
Was:
Become:
Hope it will be help somebody )