[FLOW3-general] IdentityRoutePart does not match
Peter Rauber
peter.rauber at werkraum.net
Thu Aug 23 13:45:55 CEST 2012
Hi Christian,
I would prefer to skip the mapping table. I guess you mean a
route-configuration like this:
name: 'Mypackage Article Item'
uriPattern: 'article/{article}'
defaults:
'@package': ' Mypackage'
'@controller': 'Article'
This route works as well, matches and it mapps the uuid after the
'/article/' in the request-parameter 'article'.
The problem here is, when I send a PUT-request to change some data like
this:
uri: Mypackage/article/71df811d-**8266-4742-b80f-2bc5eb628b12
Request-Data (PUT-Body):
{article:{name:'newName',otherProperty:'newValue'}
the request-parameter article (from the PUT-body) will be overwritten by
the DynamicRoutePart with the uuid-string (71df811d-**
8266-4742-b80f-2bc5eb628b12).
So the article-data (from the PUT-body) is no longer available inside the
update-method that is called in the rest-controller. Instead the
article-object from the database (via the uuid) is passed to the
update-method of the controller. But my new values (PUT-body-variables) are
not available for updating.
The IdendityRoutePart works better, it does not overwrite the
request-parameter (article-array) from the body, it just merges the
"__idendity"-key into the article-array.
IdendityRoutePart-Code:
protected function matchValue($value) {
if ($value === NULL || $value === '') {
return FALSE;
}
$objectPathMapping =
$this->objectPathMappingRepository->findOneByObjectTypeUriPatternAndPathSegment($this->objectType,
$this->getUriPattern(), $value);
if ($objectPathMapping === NULL) {
return FALSE;
}
$this->value = *array('__identity' => $objectPathMapping->getIdentifier())*;
return TRUE;
}
Fine so far, ff there would not be the problem with the mapping table that
needs to be filled.
Maybe I handle those PUT-request wrong. Any suggestion/best practice?
My next step would be an own RoutePart-Object that does it like
IdendityRoutePart, but without that table. But maybe this is not the "nice"
way.
Best regards,
Peter
From: "\"Christian Müller (FLOW3 Team)\"" <christian.mueller at typo3.org>
> To: flow3-general at lists.typo3.org
> Cc:
> Date: Thu, 23 Aug 2012 00:16:33 +0200
> Subject: Re: [FLOW3-general] IdentityRoutePart does not match
> I think the table is filled on generating a link (resolving a route) for a
> specific action / parameter combination. Which might make it difficult in
> your use case. But if I remember correctly (and there should be an example
> in the docs) you can have the object identifier much easier in the URI and
> that is then not going through the Mapping table.
>
> But I would need to check this out myself to give you a 100% answer on
> that.
>
> Christian
>
> On 22/08/12 23:30, Peter Rauber wrote:
>
>> Hi guys,
>>
>> I am using a RestController and configured a subroute in my package for
>> accessing article-resources:
>>
>> name: 'Mypackage Article Item'
>> uriPattern: 'article/{article}'
>> defaults:
>> '@package': ' Mypackage'
>> '@controller': 'Article'
>> routeParts:
>> article:
>> objectType: ' Mypackage\Domain\Model\**Article\Article'
>> uriPattern: '{__identity}'
>>
>> A sample request looks like this:
>>
>> Mypackage/article/71df811d-**8266-4742-b80f-2bc5eb628b12
>>
>> This route is never used, because the IdentityRoutePart's
>> matchValue-method
>> never returns TRUE. The reason for this is that the
>> ObjectPathMapping-table
>> in the database is empty.
>> I found out, that this table is filled from the resolveValue-method of
>> the IdentityRoutePart-object. But I did not figured out, when this method
>> is triggered.
>>
>> How can the ObjectPathMapping-table be filled? Do I have to write code to
>> fill this table? Doesn't make sense to me.
>>
>> Super-curious about any hints,
>> Peter
>>
>>
More information about the FLOW3-general
mailing list