function services_controller_execute in Services 7.3
Same name and namespace in other branches
- 6.3 services.runtime.inc \services_controller_execute()
Performs access checks and executes a services controller. This method is called by server implementations.
Parameters
array $controller: An array containing information about the controller
array $args: The arguments that should be passed to the controller.
array $options: Options for the execution. Use 'skip_authentication'=>TRUE to skip the services-specific authentication checks. Access checks will always be made.
2 calls to services_controller_execute()
- RESTServer::handle in servers/
rest_server/ includes/ RESTServer.inc - Handles the call to the REST server
- xmlrpc_server_call_wrapper in servers/
xmlrpc_server/ xmlrpc_server.module - Pass XMLRPC server requests to the appropriate services method.
File
- includes/
services.runtime.inc, line 95 - 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($controller, $args = array(), $options = array()) {
$server_info = services_server_info_object();
if (!empty($server_info->debug)) {
watchdog('services', 'Controller: <pre>@controller</pre>', array(
'@controller' => print_r($controller, TRUE),
), WATCHDOG_DEBUG);
watchdog('services', 'Passed arguments: <pre>@arguments</pre>', array(
'@arguments' => print_r($args, TRUE),
), WATCHDOG_DEBUG);
}
// Switch to anonymous user preserving currently session authenticated user.
_services_controller_execute_preserve_user_switch_anonymous($controller);
try {
$result = _services_controller_execute_internals($controller, $args, $options);
} catch (Exception $exception) {
_services_controller_execute_restore_user();
throw $exception;
}
// Restore user only if callback is not logout.
$restore_user = !is_string($controller['callback']) || strpos($controller['callback'], 'logout') === FALSE;
if ($restore_user) {
_services_controller_execute_restore_user();
}
if (!empty($server_info->debug)) {
watchdog('services', 'results: <pre>@results</pre>', array(
'@results' => print_r($result, TRUE),
), WATCHDOG_DEBUG);
}
return $result;
}