function _services_controller_execute_internals in Services 7.3
Internals of the services_controller_execute().
Arguments are the same as services_controller_execute().
1 call to _services_controller_execute_internals()
- services_controller_execute in includes/
services.runtime.inc - Performs access checks and executes a services controller. This method is called by server implementations.
File
- includes/
services.runtime.inc, line 161 - Contains functions that only are necessary when a service call is made. This has broken out so that this code isn't loaded for every page load.
Code
function _services_controller_execute_internals($controller, $args, $options) {
$server_info = services_server_info_object();
$endpoint_name = services_get_server_info('endpoint');
$endpoint = services_endpoint_load($endpoint_name);
_services_authenticate_user($controller, $endpoint, $args, $options);
// Load the proper file.
if (!empty($controller['file']) && ($file = $controller['file'])) {
module_load_include($file['type'], $file['module'], isset($file['name']) ? $file['name'] : NULL);
}
_services_run_access_callback($controller, $args);
$endpoint_path = services_get_server_info('endpoint_path', '');
$endpoint_path_len = drupal_strlen($endpoint_path) + 1;
$canonical_path = drupal_substr($_GET['q'], $endpoint_path_len, drupal_strlen($_GET['q']) - $endpoint_path_len);
// Prepare $path array and $resource_name.
$path = explode('/', $canonical_path);
$resource_name = array_shift($path);
$options['version'] = _services_version_header_options() ? _services_version_header_options() : NULL;
$options['resource'] = $resource_name;
//because index is never filled, we have to add this on an else, $remove_index is just a paranoid variable to make sure that futher code flow is not altered.
$remove_index = FALSE;
if (isset($path[0])) {
$options['method'] = $path[0];
}
else {
$options['method'] = 'index';
$remove_index = TRUE;
}
if (!empty($options['version'])) {
services_request_apply_version($controller, $options);
}
if ($remove_index) {
unset($options['method']);
}
drupal_alter('services_request_preprocess', $controller, $args, $options);
// Log the arguments.
if (!empty($server_info->debug)) {
watchdog('services', 'Called arguments: <pre>@arguments</pre>', array(
'@arguments' => print_r($args, TRUE),
), WATCHDOG_DEBUG);
}
// Execute the controller callback.
$result = call_user_func_array($controller['callback'], $args);
drupal_alter('services_request_postprocess', $controller, $args, $result);
return $result;
}