Bug #4441

Route does not correctly replace domain objects in resolve()

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

Status:
Resolved
Priority:
Should have
Category:
MVC
Start date:
2009-09-03
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Complexity:

Description

At the end of \F3\FLOW3\MVC\Web\Routing\Route::resolve() remaining objects are transformed into respective UUIDs.
But there are two issues with that:

1. values are replaced directly instead of creating an array:

$route->resolves(array('someObject' => $someObject));

expected: ?someObject[__identity]=XXXX-XXXX-XXXX-XXXX
actual: ?someObject=XXXX-XXXX-XXXX-XXXX

-

2. This does not work for multi dimensional arrays:

$route->resolves(array('foo' => array('someObject' => $someObject)));

expected: ?foo[someObject][__identity]=XXXX-XXXX-XXXX-XXXX
actual: Exception(!)

-

This might be a chance to forwardport something from extbase. There we have

protected function convertDomainObjectsToIdentityArrays(array $arguments) {
    foreach ($arguments as $argumentKey => $argumentValue) {
        if ($argumentValue instanceof Tx_Extbase_DomainObject_AbstractEntity) {
            $arguments[$argumentKey] = array('uid' => $argumentValue->getUid());
        } elseif (is_array($argumentValue)) {
            $arguments[$argumentKey] = $this->convertDomainObjectsToIdentityArrays($argumentValue);
        }
    }
    return $arguments;
}

in the new UriBuilder.

Patch follows


Files

#1

Updated by Bastian Waidelich about 12 years ago

Attached patch seems to fix the issues.

Robert Lemke: Please validate the patch and commit if applicable.

#2

Updated by Bastian Waidelich about 12 years ago

The provided patch "4441_Route_does_not_correctly_replace_domain_objects_in_resolve_v2.patch" tweaks the error message that is displayed if objects without identity are passed to the resolves() method.

#3

Updated by Bastian Waidelich about 12 years ago

Bastian Waidelich wrote:

The provided patch [...] tweaks the error message [...]

Damn it, the error message still contains a typo.. Dear comitter please fix ;)

#4

Updated by Karsten Dambekalns about 12 years ago

  • Status changed from Needs Feedback to Accepted
  • Assignee changed from Robert Lemke to Karsten Dambekalns
  • Target version set to 1.0 alpha 4
#5

Updated by Karsten Dambekalns about 12 years ago

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

Applied in changeset r3134.

Also available in: Atom PDF