serializer icon indicating copy to clipboard operation
serializer copied to clipboard

example for https://jmsyst.com/libs/serializer/master/cookbook/object_constructor

Open grekpg opened this issue 4 years ago • 1 comments

I try to setup doctrine object to populate without success. please help

https://stackoverflow.com/questions/68454962/jms-serializer-object-to-populate/69555946#69555946

grekpg avatar Oct 13 '21 13:10 grekpg

This isn't working for me either.

$context = new DeserializationContext();

$xmlImport = file_get_contents($input->getOption('path') . '/import.xml');

$configImport = $this->serializer->deserialize($xmlImport, XmlBase::class, 'xml');

$context->setAttribute('target', $configImport);

$xmlCandidate = file_get_contents($input->getOption('path') . '/candidate.xml');

$configCandidate = $this->serializer->deserialize($xmlCandidate, XmlBase::class, 'xml', $context);

dd($configCandidate);

XmlBase is the parent and contains a nested child XmlSystem.

I get this error message:

Typed property App\Entity\XmlBase::$system must be an instance of App\Entity\XmlSystem, App\Entity\XmlBase used

rcmcdonald91 avatar Oct 13 '21 17:10 rcmcdonald91