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


PHP DocumentManager::close方法代码示例

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


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

示例1: commit

 /**
  * Commits the UnitOfWork
  *
  * @param object $document
  *
  * @return void
  */
 public function commit($document = null)
 {
     $this->detectChangedDocuments($document);
     if ($this->evm->hasListeners(Event::onFlush)) {
         $this->evm->dispatchEvent(Event::onFlush, new OnFlushEventArgs($this->dm));
     }
     try {
         $utx = $this->session->getWorkspace()->getTransactionManager();
         if ($utx->inTransaction()) {
             $utx = null;
         } else {
             $utx->begin();
         }
     } catch (UnsupportedRepositoryOperationException $e) {
         $utx = null;
     }
     try {
         $this->executeInserts($this->scheduledInserts);
         $this->executeUpdates($this->scheduledUpdates);
         $this->executeUpdates($this->scheduledAssociationUpdates, false);
         $this->executeRemovals($this->scheduledRemovals);
         $this->executeMoves($this->scheduledMoves);
         $this->session->save();
         if ($utx) {
             $utx->commit();
         }
     } catch (\Exception $e) {
         try {
             $this->dm->close();
             if ($utx) {
                 $utx->rollback();
             }
         } catch (\Exception $innerException) {
             //TODO: log error while closing dm after error: $innerException->getMessage
         }
         throw $e;
     }
     foreach ($this->visitedCollections as $col) {
         $col->takeSnapshot();
     }
     foreach ($this->multivaluePropertyCollections as $col) {
         $col->takeSnapshot();
     }
     $this->documentTranslations = $this->scheduledUpdates = $this->scheduledAssociationUpdates = $this->scheduledRemovals = $this->scheduledMoves = $this->scheduledInserts = $this->visitedCollections = array();
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:52,代码来源:UnitOfWork.php

示例2: commit

 /**
  * Commits the UnitOfWork
  *
  * @param object|array|null $document optionally limit to a specific
  *                                    document or an array of documents
  */
 public function commit($document = null)
 {
     $this->invokeGlobalEvent(Event::preFlush, new ManagerEventArgs($this->dm));
     if ($document === null) {
         $this->computeChangeSets();
     } elseif (is_object($document)) {
         $this->computeSingleDocumentChangeSet($document);
     } elseif (is_array($document)) {
         foreach ($document as $object) {
             $this->computeSingleDocumentChangeSet($object);
         }
     }
     $this->invokeGlobalEvent(Event::onFlush, new ManagerEventArgs($this->dm));
     if (empty($this->scheduledInserts) && empty($this->scheduledUpdates) && empty($this->scheduledRemovals) && empty($this->scheduledReorders) && empty($this->documentTranslations) && empty($this->scheduledMoves)) {
         $this->invokeGlobalEvent(Event::postFlush, new ManagerEventArgs($this->dm));
         $this->changesetComputed = array();
         // @deprecated This is to maintain BC with the old behavior, where users may call
         //             flush instead of PHPCR\SessionInterface#save
         $this->session->save();
         return;
         // Nothing to do.
     }
     try {
         $utx = $this->session->getWorkspace()->getTransactionManager();
         if ($utx->inTransaction()) {
             $utx = null;
         } else {
             $utx->begin();
         }
     } catch (UnsupportedRepositoryOperationException $e) {
         $utx = null;
     }
     try {
         $this->executeInserts($this->scheduledInserts);
         $this->executeUpdates($this->scheduledUpdates);
         $this->executeRemovals($this->scheduledRemovals);
         $this->executeReorders($this->scheduledReorders);
         $this->executeMoves($this->scheduledMoves);
         $this->session->save();
         if ($utx) {
             $utx->commit();
         }
     } catch (\Exception $e) {
         try {
             $this->dm->close();
             if ($utx) {
                 $utx->rollback();
             }
         } catch (\Exception $innerException) {
             //TODO: log error while closing dm after error: $innerException->getMessage
         }
         throw $e;
     }
     foreach ($this->visitedCollections as $col) {
         $col->takeSnapshot();
     }
     $this->invokeGlobalEvent(Event::postFlush, new ManagerEventArgs($this->dm));
     if (null === $document) {
         foreach ($this->documentLocales as $oid => $locales) {
             $this->documentLocales[$oid]['original'] = $locales['current'];
         }
     } else {
         $documents = is_array($document) ? $document : array($document);
         foreach ($documents as $doc) {
             $oid = spl_object_hash($doc);
             if (isset($this->documentLocales[$oid])) {
                 $this->documentLocales[$oid]['original'] = $this->documentLocales[$oid]['current'];
             }
         }
     }
     $this->scheduledUpdates = $this->scheduledRemovals = $this->scheduledMoves = $this->scheduledReorders = $this->scheduledInserts = $this->visitedCollections = $this->documentChangesets = $this->changesetComputed = array();
     $this->invokeGlobalEvent(Event::endFlush, new ManagerEventArgs($this->dm));
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:79,代码来源:UnitOfWork.php


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