I have the following XML:
<CinemaListExport>
<Cinema>
....
<screens>
<screen></screen>
<screen></screen>
</screens>
</Cinema>
<Cinema>
....
</Cinema>
<CinemaListExport>
I am trying to convert this into the following objects:
class CinemaList
{
/**
* @var Cinema[]
*/
public $cinema;
public function __construct()
{
$this->cinema = new ArrayCollection();
}
public function addCinema(Cinema $cinema)
{
$this->cinema[] = $cinema;
}
class Cinema
{
fields...
/**
* @var Screen[]
*/
public $screens = [];
with the following code:
$normalizers = [
new ArrayDenormalizer(),
new ObjectNormalizer(null, null, null, new ReflectionExtractor())
];
$encoders = [new XmlEncoder()];
$serializer = new Serializer($normalizers, $encoders);
$res = $serializer->deserialize($xml, CinemaList::class, 'xml');
No matter what I do I always get the following:
class CinemaList#265 (1) {
public $cinema =>
class Doctrine\Common\Collections\ArrayCollection#317 (1) {
private $elements =>
array(0) {
}
}
}
Can anyone point me in the right direction? What am I doing wrong here? I just need CinemaList to contain all the Cinemas and each Cinema to contain all it's screens