Feature #1789

Routing: Implement automatic UUID to object conversion

Added by Bastian Waidelich about 13 years ago. Updated about 11 years ago.

Status:
Resolved
Priority:
Must have
Assignee:
Category:
MVC
Start date:
2008-10-23
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Complexity:

Description

Fluid already converts objects used as arguments for URIs (in forms and action links) to uuids and if no custom route is specified, the router adds them as regular GET parameters:

http://myhost/foo/bar?baz=297f1954-3904-4824-94c9-3b66d46f2e74

In the example above "baz" is an controller argument of some object type which has been converted to its uuid by Fluid. What we need now is the counterpart which transparently converts the uuid into an object.

#1

Updated by Karsten Dambekalns about 13 years ago

  • Priority changed from Should have to Must have
  • Target version set to 1.0 alpha 1
#2

Updated by Robert Lemke over 12 years ago

Some code snippets from T3DD09:

if (strlen($value) === 36 && preg_match('/([a-f0-9]){8}-([a-f0-9]){4}-([a-f0-9]){4}-([a-f0-9]){4}-([a-f0-9]){12}/', $value)) {
    $query = $this->queryFactory->create('F3\Blog\Domain\Model\Blog');
    $objects = $query->matching($query->withUUID($value))->execute();
    if (count($objects) !== 1 ) return FALSE;
    $value = current($objects);
}

final public function resolve(array &$routeValues) {
    $this->value = NULL;
    if ($this->name === NULL || $this->name === '') {
        return FALSE;
    }
    $valueToResolve = $this->findValueToResolve($routeValues);
    if (is_object($valueToResolve)) {
        $valueToResolve = $this->persistenceManager->getBackend()->getUUIDByObject($valueToResolve);
    }
    if (!$this->resolveValue($valueToResolve)) {
        return FALSE;
    }
    unset($routeValues[$this->name]);
    return TRUE;
}

#3

Updated by Robert Lemke over 12 years ago

  • Assignee changed from Bastian Waidelich to Robert Lemke
#4

Updated by Robert Lemke over 12 years ago

  • Status changed from New to Accepted
#5

Updated by Robert Lemke over 12 years ago

  • Subject changed from Routing: RoutePartHandler Service to Routing: Implement automatic UUID to object conversion
#6

Updated by Robert Lemke over 12 years ago

  • Status changed from Accepted to Resolved
  • % Done changed from 0 to 100

Applied in changeset r2371.

Also available in: Atom PDF