zf-fr/zfr-rest — pull request #123 by bakura10 (2014-02-16 19:19:46+00:00)
Title: Allow to fetch repository

ping @Ocramius @danizord @Orkin

This is a fix to a bug @Orkin encounters. Basically, when you go to a URL like "/users", ZfrRest router will automatically returns an EntityRepository, which is the base resource (on the other hand, because of the traversing, something like "/users/6/tweets" will return a Collection).

Although the EntityRepository is selectable, it is not iterable, and hence cannot be serialized:

```php
public function get(Selectable $users)
{
// Won't work when serialization if $users is a repository
return $this->resourceModel($users);
}
```

This PR adds a specific case when the path is empty AND no previous match has been done, by matching the repository with an empty criteria, hence forcing to return a Collection.

Please note that this PR ABSOLUTELY needs this: https://github.com/doctrine/doctrine2/pull/882 in order to be really efficient when matching paths like ("/users").