/**
* Gets the parent information for a given PersistentCollection. It will
* retrieve the top-level persistent Document that the PersistentCollection
* lives in. We can use this to issue queries when updating a
* PersistentCollection that is multiple levels deep inside an embedded
* document.
*
* <code>
* list($path, $parent) = $this->getPathAndParent($coll)
* </code>
*
* @param PersistentCollection $coll
* @return array $pathAndParent
*/
private function getPathAndParent(PersistentCollection $coll)
{
$mapping = $coll->getMapping();
$fields = array();
$parent = $coll->getOwner();
while (null !== ($association = $this->uow->getParentAssociation($parent))) {
list($m, $owner, $field) = $association;
if (isset($m['reference'])) {
break;
}
$parent = $owner;
$fields[] = $field;
}
$propertyPath = implode('.', array_reverse($fields));
$path = $mapping['name'];
if ($propertyPath) {
$path = $propertyPath . '.' . $path;
}
return array($path, $parent);
}