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


PHP UnitOfWork::getOrCreateDocument方法代码示例

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


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

示例1: current

 /**
  * @see \Doctrine\MongoDB\EagerCursor::current()
  * @see http://php.net/manual/en/iterator.current.php
  */
 public function current()
 {
     $current = parent::current();
     if ($current === null || !$this->hydrate) {
         return $current;
     }
     return $this->unitOfWork->getOrCreateDocument($this->class->name, $current, $this->unitOfWorkHints);
 }
开发者ID:im286er,项目名称:ent,代码行数:12,代码来源:EagerCursor.php

示例2: hydrateDocument

 /**
  * @param array $document
  * @return array|object|null
  */
 private function hydrateDocument($document)
 {
     if ($document !== null && $this->class !== null) {
         return $this->unitOfWork->getOrCreateDocument($this->class->name, $document);
     }
     return $document;
 }
开发者ID:doctrine,项目名称:mongodb-odm,代码行数:11,代码来源:CommandCursor.php

示例3: loadCollection

    public function loadCollection(PersistentCollection $collection)
    {
        $mapping = $collection->getMapping();
        $cmd = $this->dm->getConfiguration()->getMongoCmd();
        $groupedIds = array();
        foreach ($collection->getReferences() as $reference) {
            $className = $this->dm->getClassNameFromDiscriminatorValue($mapping, $reference);
            $id = $reference[$cmd . 'id'];
            $reference = $this->dm->getReference($className, (string) $id);
            $collection->add($reference);
            if ($reference instanceof Proxy && ! $reference->__isInitialized__) {
                if ( ! isset($groupedIds[$className])) {
                    $groupedIds[$className] = array();
                }
                $groupedIds[$className][] = $id;
            }
        }

        foreach ($groupedIds as $className => $ids) {
            $mongoCollection = $this->dm->getDocumentCollection($className);
            $data = $mongoCollection->find(array('_id' => array($cmd . 'in' => $ids)));
            $hints = array(Builder::HINT_REFRESH => true);
            foreach ($data as $id => $documentData) {
                $document = $this->uow->getOrCreateDocument($className, $documentData, $hints);
            }
        }
    }
开发者ID:pmjones,项目名称:php-framework-benchmarks,代码行数:27,代码来源:DocumentPersister.php

示例4: loadById

 /**
  * Lood document by its identifier.
  *
  * @param string $id
  * @return object|null
  */
 public function loadById($id)
 {
     $result = $this->collection->findOne(array('_id' => $this->class->getDatabaseIdentifierValue($id)));
     if ($result !== null) {
         return $this->uow->getOrCreateDocument($this->documentName, $result);
     }
     return null;
 }
开发者ID:roydonstharayil,项目名称:sugarbox,代码行数:14,代码来源:BasicDocumentPersister.php

示例5: getNext

 /**
  * Wrapper method for MongoCursor::getNext().
  *
  * If configured, the result may be a hydrated document class instance.
  *
  * @see \Doctrine\MongoDB\Cursor::getNext()
  * @see http://php.net/manual/en/mongocursor.getnext.php
  * @return array|object|null
  */
 public function getNext()
 {
     $next = $this->baseCursor->getNext();
     if ($next !== null && $this->hydrate) {
         return $this->unitOfWork->getOrCreateDocument($this->class->name, $next, $this->unitOfWorkHints);
     }
     return $next;
 }
开发者ID:im286er,项目名称:ent,代码行数:17,代码来源:Cursor.php

示例6: loadById

 /**
  * Lood document by its identifier.
  *
  * @param string $id
  * @return object|null
  */
 public function loadById($id)
 {
     $result = $this->_collection->findOne(array('_id' => $this->_class->getDatabaseIdentifierValue($id)));
     if ($result !== null) {
         $document = $this->_uow->getOrCreateDocument($this->_documentName, $result);
         $this->_uow->registerManaged($document, $this->_class->getPHPIdentifierValue($result['_id']), $result);
         return $document;
     }
     return null;
 }
开发者ID:klaasn,项目名称:symfony-sandbox,代码行数:16,代码来源:BasicDocumentPersister.php

示例7: createDocument

 /**
  * Creates or fills a single document object from an query result.
  *
  * @param object $result The query result.
  * @param object $document The document object to fill, if any.
  * @param array $hints Hints for document creation.
  * @return object The filled and managed document object or NULL, if the query result is empty.
  */
 private function createDocument($result, $document = null, array $hints = array())
 {
     if ($result === null) {
         return null;
     }
     if ($document !== null) {
         $hints[Query::HINT_REFRESH] = true;
         $id = $this->class->getPHPIdentifierValue($result['_id']);
         $this->uow->registerManaged($document, $id, $result);
     }
     return $this->uow->getOrCreateDocument($this->class->name, $result, $hints, $document);
 }
开发者ID:ttk04,项目名称:mongodb-odm,代码行数:20,代码来源:DocumentPersister.php


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