当前位置: 首页>>代码示例>>PHP>>正文


PHP UnitOfWork::getCollectionPersister方法代码示例

本文整理汇总了PHP中Doctrine\ODM\MongoDB\UnitOfWork::getCollectionPersister方法的典型用法代码示例。如果您正苦于以下问题:PHP UnitOfWork::getCollectionPersister方法的具体用法?PHP UnitOfWork::getCollectionPersister怎么用?PHP UnitOfWork::getCollectionPersister使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ODM\MongoDB\UnitOfWork的用法示例。


在下文中一共展示了UnitOfWork::getCollectionPersister方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAtomicCollectionUpdateQuery

 private function getAtomicCollectionUpdateQuery($document)
 {
     $update = array();
     $collections = $this->uow->getScheduledCollections($document);
     $collPersister = $this->uow->getCollectionPersister();
     foreach ($collections as $coll) {
         /* @var $coll PersistentCollection */
         $mapping = $coll->getMapping();
         if ($mapping['strategy'] !== "atomicSet" && $mapping['strategy'] !== "atomicSetArray") {
             continue;
         }
         if ($this->uow->isCollectionScheduledForUpdate($coll)) {
             $update = array_merge_recursive($update, $collPersister->prepareSetQuery($coll));
             $this->uow->unscheduleCollectionUpdate($coll);
             /* TODO:
              * Collection can be set for both deletion and update if
              * PersistentCollection instance was changed. Since we're dealing
              * with collection update in one query we won't need the $unset.
              * Line can be removed once the issue is fixed.
              */
             $this->uow->unscheduleCollectionDeletion($coll);
         } elseif ($this->uow->isCollectionScheduledForDeletion($coll)) {
             $update = array_merge_recursive($update, $collPersister->prepareDeleteQuery($coll));
             $this->uow->unscheduleCollectionDeletion($coll);
         }
     }
     return $update;
 }
开发者ID:uedehua,项目名称:laravel5-mongodb,代码行数:28,代码来源:DocumentPersister.php

示例2: __construct

 /**
  * Initializes a new DocumentPersister instance.
  *
  * @param PersistenceBuilder $pb
  * @param DocumentManager $dm
  * @param EventManager $evm
  * @param UnitOfWork $uow
  * @param HydratorFactory $hydratorFactory
  * @param ClassMetadata $class
  */
 public function __construct(PersistenceBuilder $pb, DocumentManager $dm, EventManager $evm, UnitOfWork $uow, HydratorFactory $hydratorFactory, ClassMetadata $class, CriteriaMerger $cm = null)
 {
     $this->pb = $pb;
     $this->dm = $dm;
     $this->evm = $evm;
     $this->cm = $cm ?: new CriteriaMerger();
     $this->uow = $uow;
     $this->hydratorFactory = $hydratorFactory;
     $this->class = $class;
     $this->collection = $dm->getDocumentCollection($class->name);
     $this->cp = $this->uow->getCollectionPersister();
 }
开发者ID:ttk04,项目名称:mongodb-odm,代码行数:22,代码来源:DocumentPersister.php

示例3: 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;
 }
开发者ID:noc-med,项目名称:mongodb-odm,代码行数:63,代码来源:DocumentPersister.php


注:本文中的Doctrine\ODM\MongoDB\UnitOfWork::getCollectionPersister方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。