Doctrine\ORM\UnitOfWork::registerManaged PHP Method

registerManaged() public method

INTERNAL: Registers an entity as managed.
public registerManaged ( object $entity, array $id, array $data )
$entity object The entity.
$id array The identifier values.
$data array The original entity data.
    public function registerManaged($entity, array $id, array $data)
    {
        $oid = spl_object_hash($entity);
        $this->entityIdentifiers[$oid] = $id;
        $this->entityStates[$oid] = self::STATE_MANAGED;
        $this->originalEntityData[$oid] = $data;
        $this->addToIdentityMap($entity);
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function loadCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, EntityCacheEntry $entry, $entity = null)
 {
     $data = $entry->data;
     $hints = self::$hints;
     if ($entity !== null) {
         $hints[Query::HINT_REFRESH] = true;
         $hints[Query::HINT_REFRESH_ENTITY] = $entity;
     }
     foreach ($metadata->associationMappings as $name => $assoc) {
         if (!isset($assoc['cache']) || !isset($data[$name])) {
             continue;
         }
         $assocClass = $data[$name]->class;
         $assocId = $data[$name]->identifier;
         $isEagerLoad = $assoc['fetch'] === ClassMetadata::FETCH_EAGER || $assoc['type'] === ClassMetadata::ONE_TO_ONE && !$assoc['isOwningSide'];
         if (!$isEagerLoad) {
             $data[$name] = $this->em->getReference($assocClass, $assocId);
             continue;
         }
         $assocKey = new EntityCacheKey($assoc['targetEntity'], $assocId);
         $assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']);
         $assocRegion = $assocPersister->getCacheRegion();
         $assocEntry = $assocRegion->get($assocKey);
         if ($assocEntry === null) {
             return null;
         }
         $data[$name] = $this->uow->createEntity($assocEntry->class, $assocEntry->resolveAssociationEntries($this->em), $hints);
     }
     if ($entity !== null) {
         $this->uow->registerManaged($entity, $key->identifier, $data);
     }
     $result = $this->uow->createEntity($entry->class, $data, $hints);
     $this->uow->hydrationComplete();
     return $result;
 }
All Usage Examples Of Doctrine\ORM\UnitOfWork::registerManaged