我有XML格式
<POS>
<Source PseudoCCode="BOA" ISOCountry="US" AgentDutyCode="J114N">
<RequestorID Type="11" ID="T921">
<CompanyName Code="CP" CodeContext="123T"/>
</RequestorID>
</Source>
<Source>
<RequestorID Type="1" ID="34778"/>
</Source>
<Source>
<RequestorID Type="9" ID="ZF"/>
</Source>
<Source>
<RequestorID Type="17" ID="mabaan"/>
</Source>
</POS>
`
我有一个要反序列化的php对象。
class POS
{
/**
* @ORM\OneToMany(targetEntity="POS_Source", mappedBy="POS", orphanRemoval=true)
* @Groups("Include")
*/
private $Source;
public function __construct()
{
$this->Source = new ArrayCollection();
}
/**
* @return ArrayCollection|OTA_POS_Source[]
*/
public function getSource(): ArrayCollection
{
return $this->Source;
}
public function addSource(POS_Source $source): self
{
if (!$this->Source->contains($source)) {
$this->Source[] = $source;
$source->setPOS($this);
}
return $this;
}
public function removeSource(POS_Source $source): self
{
if ($this->Source->contains($source)) {
$this->Source->removeElement($source);
// set the owning side to null (unless already changed)
if ($source->getPOS() === $this) {
$source->setPOS(null);
}
}
return $this;
}
它给了我POS对象,而不是给它一个下面的数组,而不是POS_Source对象的集合。
POS {#839 ▼
-id: null
-Source: array:5 [▼
0 => array:4 [▶]
1 => array:1 [▶]
2 => array:1 [▶]
3 => array:1 [▶]
4 => array:1 [▶]
]
}
我如何才能使这项工作一直填充到对象树的底部。当我从对象结构序列化为XML时,它的效果很好。
largeQ
POPMUISE
宝慕林4294392