当前位置: 首页>>代码示例>>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;未经允许,请勿转载。