/** * Replaces the given object by the second object. * * This method will unregister the existing object at the identity map and * register the new object instead. The existing object must therefore * already be registered at the identity map which is the case for all * reconstituted objects. * * The new object will be identified by the UUID which formerly belonged * to the existing object. The existing object looses its uuid. * * @param object $existingObject The existing object * @param object $newObject The new object * @return void * @author Robert Lemke <*****@*****.**> * @author Karsten Dambekalns <*****@*****.**> */ public function replaceObject($existingObject, $newObject) { $existingUUID = $this->persistenceSession->getIdentifierByObject($existingObject); if ($existingUUID === NULL) { throw new \F3\FLOW3\Persistence\Exception\UnknownObjectException('The given object is unknown to the persistence session.', 1238070163); } $this->persistenceSession->unregisterObject($existingObject); $this->persistenceSession->registerObject($newObject, $existingUUID); }
/** * Maps a single record into the object it represents and registers it as * reconstituted with the session. * * @param array $objectData * @return object * @author Karsten Dambekalns <*****@*****.**> */ public function mapToObject(array $objectData) { if ($this->persistenceSession->hasIdentifier($objectData['identifier'])) { return $this->persistenceSession->getObjectByIdentifier($objectData['identifier']); } else { $className = $objectData['classname']; $classSchema = $this->reflectionService->getClassSchema($className); $objectConfiguration = $this->objectManager->getObjectConfiguration($className); $object = $this->objectBuilder->createEmptyObject($className, $objectConfiguration); $this->persistenceSession->registerObject($object, $objectData['identifier']); $this->objectBuilder->reinjectDependencies($object, $objectConfiguration); $this->thawProperties($object, $objectData['identifier'], $objectData, $classSchema); $object->FLOW3_Persistence_memorizeCleanState(); $this->persistenceSession->registerReconstitutedObject($object); return $object; } }