/**
  * 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);
 }
 /**
  * Returns the (internal) identifier for the object, if it is known to the
  * backend. Otherwise NULL is returned.
  *
  * Note: this returns an identifier even if the object has not been
  * persisted in case of AOP-managed entities. Use isNewObject() if you need
  * to distinguish those cases.
  *
  * @param object $object
  * @return string The identifier for the object
  * @author Karsten Dambekalns <*****@*****.**>
  * @api
  */
 public function getIdentifierByObject($object)
 {
     if ($this->persistenceSession->hasObject($object)) {
         return $this->persistenceSession->getIdentifierByObject($object);
     } elseif ($object instanceof \F3\FLOW3\AOP\ProxyInterface && $object->FLOW3_AOP_Proxy_hasProperty('FLOW3_Persistence_Entity_UUID')) {
         // entities created get an UUID set through AOP
         return $object->FLOW3_AOP_Proxy_getProperty('FLOW3_Persistence_Entity_UUID');
     } elseif ($object instanceof \F3\FLOW3\AOP\ProxyInterface && $object->FLOW3_AOP_Proxy_hasProperty('FLOW3_Persistence_ValueObject_Hash')) {
         // valueobjects created get a hash set through AOP
         return $object->FLOW3_AOP_Proxy_getProperty('FLOW3_Persistence_ValueObject_Hash');
     } else {
         return NULL;
     }
 }