I want to deserialize an XML file into an Entity using JMS Serializer. It works pretty well for direct properties. But when it comes to nested properties, I can't make it work without creating related entities. For example :
<idt>
<rcs>XXXXXXX</rcs>
<name>NAME</name>
<main>
<adr_1>
<type>YYYYY</type>
<street>YYYYYYY</street>
<zip>XXXXX</zip>
</adr_1>
</main>
</idt>
I need to create an Idt
entity, and the deserialization will work fine for rcs
and name
, but for main
I have to create a Main
entity with a OneToOne
relation that contains a Adr1
entity that contains type
, street
and zip
properties. This is pretty heavy. Is there any way to tell the serializer the path to hydrate a property? Something of the like :
class XmlRawExecutive
{
/**
* @var integer
*
* @ORM\Column(name="rcs", type="string", length=3, nullable=false)
* @JMS\Type("string")
*/
private $rcs;
/**
* @var integer
*
* @ORM\Column(name="main_adr1_street", type="integer", nullable=false)
* @JMS\Type("string")
*/
private $mainAdr1Street;
So I can hydrate a unique entity from the XML.