Posted by jrreid on January 4, 2012 at 9:20pm
2 followers
Jump to:
| Project: | Services |
| Version: | 7.x-3.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Is there any way to provide a 'value' type argument in a resource definition? I may be missing this and its just something that needs to be documented, or its something thats missing that I feel would be very helpful to have.
The use case is one where I'd like to call a hook and provide one of the arguments that is not user-enterable (similar in concept to how you can do it in hook_menu with providing a string in the callback arguments array, or even in the access arguments array in hook_services_resources itself)
For instance something like this:
<?php
function mymodule_services_resources() {
return array(
'mymodule' => array(
'get_person' => array(
'help' => 'Retrieves a person',
'callback' => 'mymodule_hookname',
'access callback' => 'user_access',
'access arguments' => array('can access people'),
'access arguments append' => TRUE,
'args' => array(
array(
'name' => 'myparam',
'type' => 'string',
'source' => 'value',
'value' => 'get_person',
),
array(
'name' => 'id',
'type' => 'int',
'description' => 'The id of the person to get',
'source' => array('path' => '0'),
'optional' => FALSE,
),
),
),
),
);
}
?>Any help in pointing me the right direction if its already doable, or if its not then I can look at rolling a patch to add this.
Comments
#1
If it is a hardcoded value why not just expose it as an variable internal to the callback?
#2
The issue with that is that the callback may be registered for multiple resources, and internally it decides based on the value some of its logic. Essentially right now we have 3 functions defined to handle 2 resources but if we can pass a value into the callback we can reduce that to a single function (between the 2 resources there is one of about 400 lines of code different)