Php 条令ODM:PersistentCollection::toArray返回空数组

Php 条令ODM:PersistentCollection::toArray返回空数组,php,mongodb,symfony,doctrine-orm,odm,Php,Mongodb,Symfony,Doctrine Orm,Odm,以下是主文档字段的定义: /** * @var ArrayCollection * @MongoDB\ReferenceMany( * targetDocument="Some\Namespace\Document\Reference", * sort={"creationDate": "desc"}, * simple=true * ) * @Expose * @Groups({"Main"}) * @Type("ArrayCollection&

以下是主文档字段的定义:

/**
 * @var ArrayCollection
 * @MongoDB\ReferenceMany(
 *      targetDocument="Some\Namespace\Document\Reference",
 *      sort={"creationDate": "desc"},
 *      simple=true
 * )
 * @Expose
 * @Groups({"Main"})
 * @Type("ArrayCollection<Some\Namespace\Document\Reference>")
 * @var \Some\Namespace\Document\Reference[]
 */
protected $references;
但这只是一条捷径,我觉得这不是一个合适的解决办法

若有人知道如何使用PersistentCollection检索这些ID或整个文档,为什么initialize方法会清除mongoData

谢谢

/**
 * @VirtualProperty
 * @SerializedName("reference_ids")
 * @Groups("Main")
 * @return array
 */
public function getReferenceIds()
{
    $out = array();

    foreach ($this->getReferences()->getMongoData() as $val) {
        $out[] = (string)$val;
    }

    return $out;
}