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