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


PHP MongoDBException::invalidDocumentState方法代码示例

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


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

示例1: doRemove

 /**
  * Deletes a document as part of the current unit of work.
  *
  * This method is internally called during delete() cascades as it tracks
  * the already visited documents to prevent infinite recursions.
  *
  * @param object $document The document to delete.
  * @param array $visited The map of the already visited documents.
  * @throws MongoDBException
  */
 private function doRemove($document, array &$visited)
 {
     $oid = spl_object_hash($document);
     if (isset($visited[$oid])) {
         return;
         // Prevent infinite recursion
     }
     $visited[$oid] = $document;
     // mark visited
     /* Cascade first, because scheduleForDelete() removes the entity from
      * the identity map, which can cause problems when a lazy Proxy has to
      * be initialized for the cascade operation.
      */
     $this->cascadeRemove($document, $visited);
     $class = $this->dm->getClassMetadata(get_class($document));
     $documentState = $this->getDocumentState($document);
     switch ($documentState) {
         case self::STATE_NEW:
         case self::STATE_REMOVED:
             // nothing to do
             break;
         case self::STATE_MANAGED:
             if (!empty($class->lifecycleCallbacks[Events::preRemove])) {
                 $class->invokeLifecycleCallbacks(Events::preRemove, $document);
             }
             if ($this->evm->hasListeners(Events::preRemove)) {
                 $this->evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($document, $this->dm));
             }
             $this->scheduleForDelete($document);
             break;
         case self::STATE_DETACHED:
             throw MongoDBException::detachedDocumentCannotBeRemoved();
         default:
             throw MongoDBException::invalidDocumentState($documentState);
     }
 }
开发者ID:kevinyien,项目名称:mongodb-odm,代码行数:46,代码来源:UnitOfWork.php

示例2: doRemove

 /**
  * Deletes an document as part of the current unit of work.
  *
  * This method is internally called during delete() cascades as it tracks
  * the already visited documents to prevent infinite recursions.
  *
  * @param object $document The document to delete.
  * @param array $visited The map of the already visited documents.
  * @throws InvalidArgumentException If the instance is a detached document.
  */
 private function doRemove($document, array &$visited)
 {
     $oid = spl_object_hash($document);
     if (isset($visited[$oid])) {
         return;
         // Prevent infinite recursion
     }
     $visited[$oid] = $document;
     // mark visited
     $class = $this->dm->getClassMetadata(get_class($document));
     $documentState = $this->getDocumentState($document);
     switch ($documentState) {
         case self::STATE_NEW:
         case self::STATE_REMOVED:
             // nothing to do
             break;
         case self::STATE_MANAGED:
             if (isset($class->lifecycleCallbacks[Events::preRemove])) {
                 $class->invokeLifecycleCallbacks(Events::preRemove, $document);
             }
             if ($this->evm->hasListeners(Events::preRemove)) {
                 $this->evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($document, $this->dm));
             }
             $this->scheduleForDelete($document);
             $this->cascadePreRemove($class, $document);
             break;
         case self::STATE_DETACHED:
             throw MongoDBException::detachedDocumentCannotBeRemoved();
         default:
             throw MongoDBException::invalidDocumentState($documentState);
     }
     $this->cascadeRemove($document, $visited);
 }
开发者ID:nextmotion,项目名称:mongodb-odm,代码行数:43,代码来源:UnitOfWork.php


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