zfcampus/zf-rest — pull request #3 by TomHAnderson (2013-11-04 01:22:14+00:00)
Title: Inject entity_class into resources

The entity_class was not available to the resource handling a rest request. Most variables in the config zf-rest controller array are set on the controller but entity_class is not needed or handled by the controller. So it must belong somewhere else to be of best use.

Described by zf-apigility as 'Name of entity class to which to hydrate' this parameter is not needed by the resource in db connected resources. But when the entity is in the context of a code-connected resource, like Doctrine, the ability to have one resource per entity, and giving that data to the resource, is quite powerful.

Assigning the entity to the resource also configured for the same controller gives the developer access to this config-level data. Access to all the controller config data through the resource is not needed as most data is used to configure the controller but the entity_class is not that kind of data. It should be injected into the resource.