Services entity dynamic resource controller
Categories
Component ID
2826704
Component name
Services entity dynamic resource controller
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
Services entity dynamic resource controller
Introduces a Services Entity resource controller which invokes a hook at request-time to determine which resource controller to use.
It is designed to facilitate the creation of multiple endpoints which expose the same entities but have a different behaviour to each other.
When to use this module
When you want to tweak the query-time behaviour of an existing operation for one endpoint but not the other, where both endpoints are exposing identical resources. For example:
- To expose the same node data but with different API data structures:
- /mucky/entity_node - results are structured using the Generic Entity Processor
- /clean/entity_node - results are structured using the Clean Entity Processor.
When NOT to use this module
- Do not use this module if you simply want to take over the resource controller for a certain entity type. Instead add your class name as the 'resource controller' in its entity info via hook_entity_info_alter(). Doing this will safely override the influence of Service entity dynamic resource controller.
- Do not use this module to override the resourceInfo() being returned. This *will not work* as the override will not be active when services builds its resource info arrays on cache clear. Instead, define your own resource via hook_services_resources().
Usage
- Install the module (as normal)
- Go to admin/config/services/services-entity
- Choose "Dynamically determined at request time" under "Default Entity Resource Class"
- Under "Dynamic resource class settings" choose which resource controller to use by default.
To override the controller for a certain endpoint:
- Edit your endpoint: visit admin/structure/services and under Operations click "Edit"
- Under "Dynamic resource class settings" choose which resource controller to use.
Advanced usage
Custom modules can implement a hook to suggest a resource controller using arbitrary logic. For full documentation see services_entity_dynamic_resource_controller.api.php
