zf-fr/zfr-rest — pull request #152 by bakura10 (2014-04-23 12:47:39+00:00)
Title: [WIP] Add support for override resource and collection controllers

Hi,

This is a first try to bring support for #151. It's not tested yet.

It was harder than what I thought. Intuitively, I wanted to add a "getMatchedController" to the SubPathMath. But this is problematic. Let's use an exemple: we want to match the resource for the URL /users/5/tweets

If we added the matched controller at each step, this needs that ZfrRest user needs to define a collection controller in User mapping (for the /users part), a resource controller for the users part (the /5) and a collection controller in Tweet mapping (for the /tweets part).

As of today, ZfrRest only extract the controller for the matched part (which is logical), so the previous code can work only if user defines a collection controller for tweets part. If the user does not need a collection controller for /users, the code won't fail. But it will if we need a matched controller at each step of the process.

Therefore, I added some more logic in the ResourceGraphRoute to first check the previous match, use the matched path to see if the association mapping contains info.

Actually, I think this code is a bit broken, because for URL like "/users/5/tweets/6", if we have the following mapping:

```php
class User
{
/**
* @REST\Association(resourceController="UserTweetController")
*/
protected $tweets;
}
```

I'd expect the tweet n°6 to be dispatched to the "UserTweetController". But with the logic in the PR, the previous match will be the "/6" part, which is a tweet.

If anyone has any idea about thow to implement that correctly (or want to give it a try...).