function drupalgap_flag_services_request_postprocess_alter in DrupalGap 7
Implements hook_services_request_postprocess_alter().
File
- modules/
drupalgap_flag/ drupalgap_flag.module, line 6
Code
function drupalgap_flag_services_request_postprocess_alter($controller, $args, &$result) {
if ($controller['callback'] == '_system_resource_connect') {
// Add flag data to the result.
$flags = db_select('flag', 'f')
->fields('f')
->execute()
->fetchAll();
if (isset($flags)) {
foreach ($flags as $flag) {
$result->flag[$flag->fid] = $flag;
$result->flag[$flag->fid]->options = unserialize($flag->options);
$types = db_select('flag_types', 'ft')
->condition('fid', $flag->fid)
->fields('ft', array(
'type',
))
->execute();
if (isset($types)) {
$result->flag[$flag->fid]->types = array();
foreach ($types as $type) {
$result->flag[$flag->fid]->types[] = $type->type;
}
}
}
}
}
}