當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UnitOfWork::getOriginalEntityData方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\UnitOfWork::getOriginalEntityData方法的典型用法代碼示例。如果您正苦於以下問題:PHP UnitOfWork::getOriginalEntityData方法的具體用法?PHP UnitOfWork::getOriginalEntityData怎麽用?PHP UnitOfWork::getOriginalEntityData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\UnitOfWork的用法示例。


在下文中一共展示了UnitOfWork::getOriginalEntityData方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: buildCacheEntry

 /**
  * {@inheritdoc}
  */
 public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, $entity)
 {
     $data = $this->uow->getOriginalEntityData($entity);
     $data = array_merge($data, $key->identifier);
     // why update has no identifier values ?
     foreach ($metadata->associationMappings as $name => $assoc) {
         if (!isset($data[$name])) {
             continue;
         }
         if (!isset($assoc['cache']) || !($assoc['type'] & ClassMetadata::TO_ONE)) {
             unset($data[$name]);
             continue;
         }
         if (!isset($assoc['id'])) {
             $targetClass = ClassUtils::getClass($data[$name]);
             $targetId = $this->uow->getEntityIdentifier($data[$name]);
             $data[$name] = new AssociationCacheEntry($targetClass, $targetId);
             continue;
         }
         // handle association identifier
         $targetId = is_object($data[$name]) && $this->uow->isInIdentityMap($data[$name]) ? $this->uow->getEntityIdentifier($data[$name]) : $data[$name];
         // @TODO - fix it !
         // handle UnitOfWork#createEntity hash generation
         if (!is_array($targetId)) {
             $data[reset($assoc['joinColumnFieldNames'])] = $targetId;
             $targetEntity = $this->em->getClassMetadata($assoc['targetEntity']);
             $targetId = array($targetEntity->identifier[0] => $targetId);
         }
         $data[$name] = new AssociationCacheEntry($assoc['targetEntity'], $targetId);
     }
     return new EntityCacheEntry($metadata->name, $data);
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:35,代碼來源:DefaultEntityHydrator.php

示例2: buildCacheEntry

 /**
  * {@inheritdoc}
  */
 public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, $entity)
 {
     $data = $this->uow->getOriginalEntityData($entity);
     $data = array_merge($data, $metadata->getIdentifierValues($entity));
     // why update has no identifier values ?
     foreach ($metadata->associationMappings as $name => $assoc) {
         if (!isset($data[$name])) {
             continue;
         }
         if (!($assoc['type'] & ClassMetadata::TO_ONE)) {
             unset($data[$name]);
             continue;
         }
         if (!isset($assoc['cache'])) {
             $targetClassMetadata = $this->em->getClassMetadata($assoc['targetEntity']);
             $owningAssociation = !$assoc['isOwningSide'] ? $targetClassMetadata->associationMappings[$assoc['mappedBy']] : $assoc;
             $associationIds = $this->identifierFlattener->flattenIdentifier($targetClassMetadata, $targetClassMetadata->getIdentifierValues($data[$name]));
             unset($data[$name]);
             foreach ($associationIds as $fieldName => $fieldValue) {
                 if (isset($targetClassMetadata->fieldMappings[$fieldName])) {
                     $fieldMapping = $targetClassMetadata->fieldMappings[$fieldName];
                     $data[$owningAssociation['targetToSourceKeyColumns'][$fieldMapping['columnName']]] = $fieldValue;
                     continue;
                 }
                 $targetAssoc = $targetClassMetadata->associationMappings[$fieldName];
                 foreach ($assoc['targetToSourceKeyColumns'] as $referencedColumn => $localColumn) {
                     if (isset($targetAssoc['sourceToTargetKeyColumns'][$referencedColumn])) {
                         $data[$localColumn] = $fieldValue;
                     }
                 }
             }
             continue;
         }
         if (!isset($assoc['id'])) {
             $targetClass = ClassUtils::getClass($data[$name]);
             $targetId = $this->uow->getEntityIdentifier($data[$name]);
             $data[$name] = new AssociationCacheEntry($targetClass, $targetId);
             continue;
         }
         // handle association identifier
         $targetId = is_object($data[$name]) && $this->uow->isInIdentityMap($data[$name]) ? $this->uow->getEntityIdentifier($data[$name]) : $data[$name];
         // @TODO - fix it !
         // handle UnitOfWork#createEntity hash generation
         if (!is_array($targetId)) {
             $data[reset($assoc['joinColumnFieldNames'])] = $targetId;
             $targetEntity = $this->em->getClassMetadata($assoc['targetEntity']);
             $targetId = [$targetEntity->identifier[0] => $targetId];
         }
         $data[$name] = new AssociationCacheEntry($assoc['targetEntity'], $targetId);
     }
     return new EntityCacheEntry($metadata->name, $data);
 }
開發者ID:AdactiveSAS,項目名稱:doctrine2,代碼行數:55,代碼來源:DefaultEntityHydrator.php

示例3: getOriginalEntityData

 /**
  * get original entity data, including versioned field, if "version" constraint is used
  *
  * @param mixed $entity
  * @return array
  */
 private function getOriginalEntityData($entity)
 {
     $class = $this->em->getClassMetadata(get_class($entity));
     $data = $this->uow->getOriginalEntityData($entity);
     if ($class->isVersioned) {
         $versionField = $class->versionField;
         $data[$versionField] = $class->reflFields[$versionField]->getValue($entity);
     }
     return $data;
 }
開發者ID:hayloft,項目名稱:EntityAudit,代碼行數:16,代碼來源:LogRevisionsListener.php


注:本文中的Doctrine\ORM\UnitOfWork::getOriginalEntityData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。