本文整理汇总了PHP中Doctrine\ODM\MongoDB\UnitOfWork::getParentAssociation方法的典型用法代码示例。如果您正苦于以下问题:PHP UnitOfWork::getParentAssociation方法的具体用法?PHP UnitOfWork::getParentAssociation怎么用?PHP UnitOfWork::getParentAssociation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ODM\MongoDB\UnitOfWork
的用法示例。
在下文中一共展示了UnitOfWork::getParentAssociation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isPartOfAtomicUpdate
/**
* @param object $embeddeDoc
* @return bool
*/
private function isPartOfAtomicUpdate($embeddeDoc)
{
$isInDirtyCollection = false;
while (null !== ($parentAssoc = $this->uow->getParentAssociation($embeddeDoc))) {
list($mapping, $embeddeDoc, ) = $parentAssoc;
if ($mapping['association'] === ClassMetadata::EMBED_MANY) {
$classMetadata = $this->dm->getClassMetadata(get_class($embeddeDoc));
$parentColl = $classMetadata->getFieldValue($embeddeDoc, $mapping['fieldName']);
$isInDirtyCollection |= $parentColl->isDirty();
}
}
return isset($mapping['association']) && $mapping['association'] === ClassMetadata::EMBED_MANY && ($mapping['strategy'] === 'atomicSet' || $mapping['strategy'] === 'atomicSetArray') && $isInDirtyCollection;
}
示例2: getAtomicCollectionUpdateQuery
private function getAtomicCollectionUpdateQuery($document)
{
$update = array();
$atomicCollUpdates = array();
$atomicCollDeletes = array();
$collPersister = $this->uow->getCollectionPersister();
/* Collect all atomic collections (top-level and nested) to be included
* in the update.
*/
foreach ($this->uow->getScheduledCollections($document) as $coll) {
/* If this is a top-level, atomic collection, its scheduled update
* or deletion must be included in the document's update query.
*/
if ($coll->getOwner() === $document) {
$mapping = $coll->getMapping();
if ($mapping['strategy'] !== "atomicSet" && $mapping['strategy'] !== "atomicSetArray") {
continue;
}
if ($this->uow->isCollectionScheduledForUpdate($coll)) {
$atomicCollUpdates[spl_object_hash($coll)] = $coll;
} elseif ($this->uow->isCollectionScheduledForDeletion($coll)) {
$atomicCollDeletes[spl_object_hash($coll)] = $coll;
}
continue;
}
/* Otherwise, the collection is nested. Check if its top-most parent
* is an atomic collection and include it for updating if so. This
* is necessary because the atomic parent may not have directly
* changed.
*/
$parent = $coll->getOwner();
while (null !== ($parentAssoc = $this->uow->getParentAssociation($parent))) {
list($mapping, $parent, ) = $parentAssoc;
}
if (!isset($mapping['association']) || $mapping['association'] !== ClassMetadata::EMBED_MANY || $mapping['strategy'] !== 'atomicSet' && $mapping['strategy'] !== 'atomicSetArray') {
continue;
}
$classMetadata = $this->dm->getClassMetadata(get_class($document));
$parentColl = $classMetadata->getFieldValue($document, $mapping['fieldName']);
/* It's possible that the atomic parent was independently scheduled
* for deletion. In that case, updating nested data is unnecessary.
*/
if (!$this->uow->isCollectionScheduledForDeletion($parentColl)) {
$atomicCollUpdates[spl_object_hash($parentColl)] = $parentColl;
}
}
foreach ($atomicCollUpdates as $coll) {
$update = array_merge_recursive($update, $collPersister->prepareSetQuery($coll));
/* Note: If the collection is only be handled because it's an atomic
* parent of a scheduled child, the following calls are NOPs.
*/
$this->uow->unscheduleCollectionUpdate($coll);
}
foreach ($atomicCollDeletes as $coll) {
$update = array_merge_recursive($update, $collPersister->prepareDeleteQuery($coll));
/* Note: We don't need to call unscheduleCollectionUpdate(), because
* the collection should never have been added to $atomicCollDeletes
* if it was independently scheduled for update.
*/
$this->uow->unscheduleCollectionDeletion($coll);
}
return $update;
}