zf-fr/zfr-rest — pull request #138 by bakura10 (2014-03-16 17:38:06+00:00)
Title: Add an object repository plugin manager

Ping @Ocramius @danizord

This PR adds an ObjectRepositoryPluginManager. The idea is to remove completely the need to create pointless factories for each object repository, when you specify it in the router.

This also improves performance if you have a lot of routes. Basically, if you had 10 ZfrRest routes, it previously had to create 10 object repository, even though there were never used. Instead, a single ObjectRepositoryPluginManager is injected and the repository is fetched only when needed.

One important BC: where you previously had this config:

```php
return [
'router' => [
'routes' => [
'users' => [
'type' => 'ResourceGraphRoute',
'options' => [
'route' => '/users',
'resource' => 'UserRepository'
]
]
]
]
];
```

You now have this (notice the "resource" key):

```php
return [
'router' => [
'routes' => [
'users' => [
'type' => 'ResourceGraphRoute',
'options' => [
'route' => '/users',
'resource' => 'User\Entity\User'
]
]
]
]
];
```

I actually think that it makes more sense.

One minor drawback: previously the "initial parameter" could be anything (an ObjectRepository, but also any other classes that was Selectable). Now, only ObjectRepository is allowed, as it is fetched internally from the plugin manager. Honestly, I can't think of a way where setting anything else than an ObjectRepository made sense. It always was the entry point of the routes. So I think the better ease of use outperforms this little lack of flexibility.