DrupalGap
DrupalGap copied to clipboard
Custom Service w/ Args - how are the args passed to the computing f(x) on Drupal Side
Aloha again there,
I was examining the code from the DrupalGap docs, and was wondering in your D7 DrupalGap docs for Creating a Custom Service w/ args, how the 'my_param' translates to the following function for $uid on the Drupal Services Side ...
function my_module_get_user_email($uid) {
$query = db_select('users', 'u')
->fields('u', array('mail'))
->condition('uid', $uid, '=');
$result = $query->execute();
return $result->fetchField();
}
I.e. is this an array, or does it simply return a single integer variable, since there is only one argument in this function :?
function my_module_services_resources() {
$resources = array(
'my_module_resources' => array(
'actions' => array(
'get_user_email' => array(
'help' => t('Gets user email of uid passed.'),
'file' => array(
'type' => 'inc',
'module' => 'my_module',
'name' => 'my_module.resource',
),
'callback' => 'my_module_get_user_email',
'args' => array(
array(
'name' => 'my_param',
'type' => 'int',
'description' => t(' uid to pass.'),
'source' => array('data' => 'my_param'),
'optional' => FALSE,
),
),
'access callback' => '_drupalgap_resource_access',
'access callback file' => array(
'type' => 'inc',
'module' => 'drupalgap',
'name' => 'drupalgap.resource',
),
'access arguments' => array('access user profiles'),
'access arguments append' => TRUE,
),
),
),
);
return $resources;
}
Thanks,
GS
@gs9999 With JSON, it'd be like this:
{
"my_param": "fooBar"
}