/** * Replaces an object by another without any further checks. Instead of * calling this method, always call replace(). * * @param object $existingObject The existing object * @param object $newObject The new object * @author Robert Lemke <*****@*****.**> */ protected function replaceObject($existingObject, $newObject) { $persistenceSession = $this->persistenceManager->getSession(); $uuid = $this->persistenceManager->getIdentifierByObject($existingObject); if ($uuid !== NULL) { $this->persistenceManager->getBackend()->replaceObject($existingObject, $newObject); $persistenceSession->unregisterReconstitutedObject($existingObject); $persistenceSession->registerReconstitutedObject($newObject); if ($this->removedObjects->contains($existingObject)) { $this->removedObjects->detach($existingObject); $this->removedObjects->attach($newObject); } } elseif ($this->addedObjects->contains($existingObject)) { $this->addedObjects->detach($existingObject); $this->addedObjects->attach($newObject); } else { throw new \F3\FLOW3\Persistence\Exception\UnknownObjectException('The "existing object" is unknown to the persistence backend.', 1238068475); } $this->updateRecursively($newObject); }
/** * Executes the number of matching objects for the query * * @return integer The number of matching objects * @author Karsten Dambekalns <*****@*****.**> * @api */ public function count() { return $this->persistenceManager->getBackend()->getObjectCountByQuery($this); }