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


PHP UnitOfWork::getEntityState方法代码示例

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


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

示例1: isValidEntityState

 /**
  * Check if entity is in a valid state for operations.
  *
  * @param object $entity
  *
  * @return bool
  */
 protected function isValidEntityState($entity)
 {
     $entityState = $this->uow->getEntityState($entity, UnitOfWork::STATE_NEW);
     if ($entityState === UnitOfWork::STATE_NEW) {
         return false;
     }
     // If Entity is scheduled for inclusion, it is not in this collection.
     // We can assure that because it would have return true before on array check
     return !($entityState === UnitOfWork::STATE_MANAGED && $this->uow->isScheduledForInsert($entity));
 }
开发者ID:StoshSeb,项目名称:doctrine2,代码行数:17,代码来源:AbstractCollectionPersister.php

示例2: isNewEntity

 /**
  * @param object     $entity
  * @param UnitOfWork $uow
  *
  * @return bool
  */
 protected function isNewEntity($entity, UnitOfWork $uow)
 {
     $entityState = $uow->getEntityState($entity);
     return $entityState !== UnitOfWork::STATE_NEW && $entityState !== UnitOfWork::STATE_DETACHED && !$uow->isScheduledForInsert($entity);
 }
开发者ID:Maksold,项目名称:platform,代码行数:11,代码来源:DoctrineTagGenerator.php

示例3: getIdString

 /**
  * @param object     $entity
  * @param UnitOfWork $uow
  *
  * @return string
  */
 private function getIdString($entity, UnitOfWork $uow)
 {
     if ($uow->isInIdentityMap($entity)) {
         $ids = $uow->getEntityIdentifier($entity);
         $idstring = "";
         foreach ($ids as $k => $v) {
             $idstring .= $k . "=" . $v;
         }
     } else {
         $idstring = "NEWOBJECT ";
     }
     $state = $uow->getEntityState($entity);
     if ($state == UnitOfWork::STATE_NEW) {
         $idstring .= " [NEW]";
     } elseif ($state == UnitOfWork::STATE_REMOVED) {
         $idstring .= " [REMOVED]";
     } elseif ($state == UnitOfWork::STATE_MANAGED) {
         $idstring .= " [MANAGED]";
     } elseif ($state == UnitOfwork::STATE_DETACHED) {
         $idstring .= " [DETACHED]";
     }
     return $idstring;
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:29,代码来源:DebugUnitOfWorkListener.php

示例4: generatePath

 /**
  * Generates new full path and validates its uniqueness
  * @param PageLocalization $pageData
  * @return PageLocalization if changes were made
  */
 protected function generatePath(PageLocalization $pageData, $force = false)
 {
     $page = $pageData->getMaster();
     $oldPath = $pageData->getPath();
     $changes = false;
     $oldPathEntity = $pageData->getPathEntity();
     list($newPath, $active, $limited, $inSitemap) = $this->findPagePath($pageData);
     if (!$page->isRoot()) {
         if (!Path::compare($oldPath, $newPath) || $force) {
             $suffix = null;
             // Check duplicates only if path is not null
             if (!is_null($newPath)) {
                 // Additional check for path length
                 $pathString = $newPath->getPath();
                 if (mb_strlen($pathString) > 255) {
                     throw new Exception\RuntimeException('Overall path length shouldn\'t be more than 255 symbols');
                 }
                 $i = 2;
                 $e = null;
                 $pathPart = $pageData->getPathPart();
                 $pathValid = false;
                 do {
                     try {
                         $this->checkForDuplicates($pageData, $newPath);
                         $pathValid = true;
                     } catch (DuplicatePagePathException $e) {
                         if ($force) {
                             // loop stoper
                             if ($i > 101) {
                                 throw new Exception\RuntimeException("Couldn't find unique path for new page", null, $e);
                             }
                             // Will try adding unique suffix after 100 iterations
                             if ($i > 100) {
                                 $suffix = uniqid();
                             } else {
                                 $suffix = $i;
                             }
                             $pageData->setPathPart($pathPart . '-' . $suffix);
                             list($newPath, $active, $limited, $inSitemap) = $this->findPagePath($pageData);
                             $i++;
                         }
                     }
                 } while ($force && !$pathValid);
                 if ($e instanceof DuplicatePagePathException && !$pathValid) {
                     throw $e;
                 }
             }
             // Validation passed, set the new path
             $pageData->setPathData($newPath, $active, $limited, $inSitemap);
             if (!is_null($suffix)) {
                 $pageData->setTitle($pageData->getTitle() . " ({$suffix})");
             }
             $changes = true;
         }
     } elseif ($page->getLeftValue() == 1) {
         $newPath = new Path('');
         // Root page
         if (!$newPath->equals($oldPath)) {
             $changes = true;
             $pageData->setPathData($newPath, $active, $limited, $inSitemap);
         }
         // Another root page...
     } else {
         $newPath = null;
         $active = false;
         $pageData->setPathData($newPath, $active, $limited, $inSitemap);
     }
     if ($oldPathEntity->isActive() !== $active || $oldPathEntity->isVisibleInSitemap() != $inSitemap) {
         $pageData->setPathData($newPath, $active, $limited, $inSitemap);
         $changes = true;
     }
     if ($changes) {
         $pathEntity = $pageData->getPathEntity();
         $pathMetaData = $this->em->getClassMetadata($pathEntity->CN());
         $localizationMetaData = $this->em->getClassMetadata($pageData->CN());
         if ($this->unitOfWork->getEntityState($pathEntity, UnitOfWork::STATE_NEW) === UnitOfWork::STATE_NEW) {
             $this->em->persist($pathEntity);
             //			} elseif ($this->unitOfWork->getEntityState($pathEntity) === UnitOfWork::STATE_DETACHED) {
             //				$pathEntity = $this->em->merge($pathEntity);
         }
         /*
          * Add the path changes to the changeset, must call different 
          * methods depending on is the entity inside the unit of work
          * changeset
          */
         if ($this->unitOfWork->getEntityChangeSet($pathEntity)) {
             $this->unitOfWork->recomputeSingleEntityChangeSet($pathMetaData, $pathEntity);
         } else {
             $this->unitOfWork->computeChangeSet($pathMetaData, $pathEntity);
         }
         if ($this->unitOfWork->getEntityChangeSet($pageData)) {
             $this->unitOfWork->recomputeSingleEntityChangeSet($localizationMetaData, $pageData);
         } else {
             $this->unitOfWork->computeChangeSet($localizationMetaData, $pageData);
         }
//.........这里部分代码省略.........
开发者ID:sitesupra,项目名称:sitesupra,代码行数:101,代码来源:PagePathGeneratorListener.php


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