當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。