Doctrine\ORM\UnitOfWork::getOriginalEntityData PHP Method

getOriginalEntityData() public method

Gets the original data of an entity. The original data is the data that was present at the time the entity was reconstituted from the database.
public getOriginalEntityData ( object $entity ) : array
$entity object
return array
    public function getOriginalEntityData($entity)
    {
        $oid = spl_object_hash($entity);
        if (isset($this->originalEntityData[$oid])) {
            return $this->originalEntityData[$oid];
        }
        return array();
    }

Usage Example

 /**
  * {@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);
 }
All Usage Examples Of Doctrine\ORM\UnitOfWork::getOriginalEntityData