/** * Replaces an existing object with the same identifier by the given object without any further checks. * Never use this method directly, always use update(). * * @param object $modifiedObject The modified object * @author Robert Lemke <*****@*****.**> */ protected function updateObject($modifiedObject) { $uuid = $this->persistenceManager->getIdentifierByObject($modifiedObject); if ($uuid !== NULL) { $existingObject = $this->persistenceManager->getObjectByIdentifier($uuid); $this->replaceObject($existingObject, $modifiedObject); } else { throw new \F3\FLOW3\Persistence\Exception\UnknownObjectException('The "modified object" is does not have an existing counterpart in this repository.', 1249479819); } }
/** * Renders a hidden form field containing the technical identity of the given object. * * @return string A hidden field containing the Identity (UUID in FLOW3, uid in Extbase) of the given object or NULL if the object is unknown to the persistence framework * @author Robert Lemke <*****@*****.**> * @author Karsten Dambekalns <*****@*****.**> * @author Bastian Waidelich <*****@*****.**> * @see \F3\FLOW3\MVC\Controller\Argument::setValue() */ protected function renderHiddenIdentityField($object, $name) { if (!is_object($object) || !$object instanceof \F3\FLOW3\Persistence\Aspect\DirtyMonitoringInterface || $object->FLOW3_Persistence_isNew() && !$object->FLOW3_Persistence_isClone()) { return ''; } $identifier = $this->persistenceManager->getIdentifierByObject($object); if ($identifier === NULL) { return chr(10) . '<!-- Object of type ' . get_class($object) . ' is without identity -->' . chr(10); } $name = $this->prefixFieldName($name) . '[__identity]'; $this->registerFieldNameForFormTokenGeneration($name); return chr(10) . '<input type="hidden" name="' . $name . '" value="' . $identifier . '" />' . chr(10); }
/** * Recursively iterates through the specified routeValues and turns objects * into an arrays containing the UUID of the domain object. * * @param array $routeValues The routeValues to be iterated over * @return array The modified routeValues array * @author Bastian Waidelich <*****@*****.**> */ protected function convertDomainObjectsToIdentityArrays(array $routeValues) { foreach ($routeValues as $routeValueKey => $routeValue) { if (is_object($routeValue)) { $uuid = $this->persistenceManager->getIdentifierByObject($routeValue); if ($uuid === FALSE) { throw new \F3\FLOW3\MVC\Exception\InvalidArgumentValueException('Route value "' . $routeValueKey . '" is an object but is unknown to the persistence manager.', 1242417960); } $routeValues[$routeValueKey] = array('__identity' => $uuid); } elseif (is_array($routeValue)) { $routeValues[$routeValueKey] = $this->convertDomainObjectsToIdentityArrays($routeValue); } } return $routeValues; }