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


PHP UnitOfWork::getDocumentPersister方法代码示例

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


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

示例1: createReferenceManyInverseSideQuery

 /**
  * @param PersistentCollection $collection
  *
  * @return Query
  */
 public function createReferenceManyInverseSideQuery(PersistentCollection $collection)
 {
     $hints = $collection->getHints();
     $mapping = $collection->getMapping();
     $owner = $collection->getOwner();
     $ownerClass = $this->dm->getClassMetadata(get_class($owner));
     $targetClass = $this->dm->getClassMetadata($mapping['targetDocument']);
     $mappedByMapping = isset($targetClass->fieldMappings[$mapping['mappedBy']]) ? $targetClass->fieldMappings[$mapping['mappedBy']] : array();
     $mappedByFieldName = isset($mappedByMapping['simple']) && $mappedByMapping['simple'] ? $mapping['mappedBy'] : $mapping['mappedBy'] . '.$id';
     $criteria = $this->cm->merge(array($mappedByFieldName => $ownerClass->getIdentifierObject($owner)), $this->dm->getFilterCollection()->getFilterCriteria($targetClass), isset($mapping['criteria']) ? $mapping['criteria'] : array());
     $criteria = $this->uow->getDocumentPersister($mapping['targetDocument'])->prepareQueryOrNewObj($criteria);
     $qb = $this->dm->createQueryBuilder($mapping['targetDocument'])->setQueryArray($criteria);
     if (isset($mapping['sort'])) {
         $qb->sort($mapping['sort']);
     }
     if (isset($mapping['limit'])) {
         $qb->limit($mapping['limit']);
     }
     if (isset($mapping['skip'])) {
         $qb->skip($mapping['skip']);
     }
     if (!empty($hints[Query::HINT_SLAVE_OKAY])) {
         $qb->slaveOkay(true);
     }
     if (!empty($hints[Query::HINT_READ_PREFERENCE])) {
         $qb->setReadPreference($hints[Query::HINT_READ_PREFERENCE], $hints[Query::HINT_READ_PREFERENCE_TAGS]);
     }
     return $qb->getQuery();
 }
开发者ID:ttk04,项目名称:mongodb-odm,代码行数:34,代码来源:DocumentPersister.php

示例2: count

 /**
  * {@inheritdoc}
  */
 public function count()
 {
     $count = $this->coll->count();
     // If this collection is inversed and not initialized, add the count returned from the database
     if ($this->mapping['isInverseSide'] && !$this->initialized) {
         $documentPersister = $this->uow->getDocumentPersister(get_class($this->owner));
         $count += empty($this->mapping['repositoryMethod']) ? $documentPersister->createReferenceManyInverseSideQuery($this)->count() : $documentPersister->createReferenceManyWithRepositoryMethodCursor($this)->count();
     }
     return $count + ($this->initialized ? 0 : count($this->mongoData));
 }
开发者ID:dominium,项目名称:mongodb-odm,代码行数:13,代码来源:PersistentCollectionTrait.php

示例3: count

 /**
  * {@inheritdoc}
  */
 public function count()
 {
     if ($this->mapping['isInverseSide'] && !$this->initialized) {
         $documentPersister = $this->uow->getDocumentPersister(get_class($this->owner));
         $count = empty($this->mapping['repositoryMethod']) ? $documentPersister->createReferenceManyInverseSideQuery($this)->count() : $documentPersister->createReferenceManyWithRepositoryMethodCursor($this)->count();
     } else {
         $count = $this->coll->count();
     }
     return count($this->mongoData) + $count;
 }
开发者ID:briareos,项目名称:mongodb-odm,代码行数:13,代码来源:PersistentCollection.php

示例4: loadActualDataForSortedReferenceManyCollectionByIds

 /**
  * @param PersistentCollection $collection
  * @param array $groupedIds
  *
  * @throws \Doctrine\ODM\MongoDB\MongoDBException
  */
 private function loadActualDataForSortedReferenceManyCollectionByIds(PersistentCollection $collection, array $groupedIds)
 {
     $mapping = $collection->getMapping();
     $hints = $collection->getHints();
     foreach ($groupedIds as $className => $ids) {
         $class = $this->dm->getClassMetadata($className);
         $mongoCollection = $this->dm->getDocumentCollection($className);
         $criteria = $this->cm->merge(array('_id' => array('$in' => array_values($ids))), $this->dm->getFilterCollection()->getFilterCriteria($class), isset($mapping['criteria']) ? $mapping['criteria'] : array());
         $criteria = $this->uow->getDocumentPersister($className)->prepareQueryOrNewObj($criteria);
         $cursor = $mongoCollection->find($criteria);
         if (isset($mapping['sort'])) {
             $cursor->sort($mapping['sort']);
         }
         if (isset($mapping['limit'])) {
             $cursor->limit($mapping['limit']);
         }
         if (isset($mapping['skip'])) {
             $cursor->skip($mapping['skip']);
         }
         if (!empty($hints[Query::HINT_SLAVE_OKAY])) {
             $cursor->slaveOkay(true);
         }
         if (!empty($hints[Query::HINT_READ_PREFERENCE])) {
             $cursor->setReadPreference($hints[Query::HINT_READ_PREFERENCE], $hints[Query::HINT_READ_PREFERENCE_TAGS]);
         }
         $documents = $cursor->toArray(false);
         foreach ($documents as $documentData) {
             $docId = $documentData['_id'];
             $document = $this->uow->getById($docId, $class);
             $data = $this->hydratorFactory->hydrate($document, $documentData);
             $this->uow->setOriginalDocumentData($document, $data);
             $document->__isInitialized__ = true;
             $collection->add($document);
         }
     }
 }
开发者ID:briareos,项目名称:mongodb-odm,代码行数:42,代码来源:DocumentPersister.php

示例5: isScheduledForInsert

 /**
  * @param object $document
  * @return boolean
  */
 private function isScheduledForInsert($document)
 {
     return $this->uow->isScheduledForInsert($document) || $this->uow->getDocumentPersister(get_class($document))->isQueuedForInsert($document);
 }
开发者ID:noc-med,项目名称:mongodb-odm,代码行数:8,代码来源:PersistenceBuilder.php

示例6: getDocumentPersister

 protected function getDocumentPersister()
 {
     return $this->uow->getDocumentPersister($this->documentName);
 }
开发者ID:briareos,项目名称:mongodb-odm,代码行数:4,代码来源:DocumentRepository.php

示例7: findOneBy

 /**
  * Finds a single document by a set of criteria.
  *
  * @param array $criteria
  * @return object
  */
 public function findOneBy(array $criteria)
 {
     return $this->uow->getDocumentPersister($this->documentName)->load($criteria);
 }
开发者ID:romainneutron,项目名称:mongodb-odm,代码行数:10,代码来源:DocumentRepository.php

示例8: getDocumentPersister

 /**
  * @override
  */
 public function getDocumentPersister($documentName)
 {
     return isset($this->_persisterMock[$documentName]) ? $this->_persisterMock[$documentName] : parent::getDocumentPersister($documentName);
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:7,代码来源:UnitOfWorkMock.php

示例9: sort

 /**
  * Wrapper method for MongoCursor::sort().
  *
  * Field names will be prepared according to the document mapping.
  *
  * @see \Doctrine\MongoDB\Cursor::sort()
  * @see http://php.net/manual/en/mongocursor.sort.php
  * @param array $fields
  * @return self
  */
 public function sort($fields)
 {
     $fields = $this->unitOfWork->getDocumentPersister($this->class->name)->prepareSortOrProjection($fields);
     $this->baseCursor->sort($fields);
     return $this;
 }
开发者ID:im286er,项目名称:ent,代码行数:16,代码来源:Cursor.php


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