Skip to content

Instantly share code, notes, and snippets.

@cotto
Created September 14, 2011 19:51
Show Gist options
  • Save cotto/1217585 to your computer and use it in GitHub Desktop.
Save cotto/1217585 to your computer and use it in GitHub Desktop.
/**
* implementation of hook_services_resources_alter()
*/
function localnet_services_services_resources_alter(&$resources, &$endpoint) {
// NOTE: services resources are cached. 'services:*' needs to be cleared from cache for this to take effect
#watchdog('res', ppr($resources));
#watchdog('endpt', ppr($endpoint));
if (array_key_exists('node', $resources) && array_key_exists('index', $resources['node'])) {
// change callback, store the name of the default callback
variable_set('serivces_default_node_index_callback', $resources['node']['index']['callback']);
$resources['node']['index']['callback'] = '_localnet_services_node_index_resource_override';
// alter node index resource to load this file
$resources['node']['index']['file'] = array(
'type' => 'module',
'module' => 'localnet_services',
'name' => 'localnet_services',
);
// alter node index resource to add the all_fields argument
$resources['node']['index']['args'][] = array(
'name' => 'all_fields',
'optional' => 1,
'type' => 'int',
'description' => "Use node_load to return all node fields.",
'default value' => 0,
'source' => array( 'param' => 'all_fields' ),
);
}
if (array_key_exists('node', $resources) && array_key_exists('retrieve', $resources['node'])) {
// change callback, store the name of the default callback
variable_set('serivces_default_node_retrieve_callback', $resources['node']['retrieve']['callback']);
$resources['node']['retrieve']['callback'] = '_localnet_services_node_retrieve_resource_override';
// alter node index resource to load this file
$resources['node']['retrieve']['file'] = array(
'type' => 'module',
'module' => 'localnet_services',
'name' => 'localnet_services',
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment