function services_request_apply_version in Services 7.3
Apply versions to the controller.
Parameters
$controller: A controller array.
$options: A options array filled with verison information.
Return value
An array with the major and minor api versions
2 calls to services_request_apply_version()
- RESTServer::resolveControllerApplyVersion in servers/
rest_server/ includes/ RESTServer.inc - Wrapper around resolveController() to apply version.
- _services_controller_execute_internals in includes/
services.runtime.inc - Internals of the services_controller_execute().
File
- ./
services.module, line 845 - Provides a generic but powerful API for web services.
Code
function services_request_apply_version(&$controller, $options = array()) {
if (isset($options)) {
extract($options);
}
if (isset($version) && $version == '1.0') {
//do nothing
return;
}
$updates = services_get_updates();
if (isset($method) && isset($updates[$resource][$method])) {
foreach ($updates[$resource][$method] as $update) {
if (!isset($version)) {
$endpoint = services_get_server_info('endpoint', '');
$endpoint = services_endpoint_load($endpoint);
$default_version = services_get_resource_api_version($endpoint, $resource, $method);
}
else {
$default_version = explode('.', $version);
$default_version['major'] = $default_version[0];
$default_version['minor'] = $default_version[1];
}
// Apply updates until we hit our default update for the site.
if ($update['major'] <= $default_version['major'] && $update['minor'] <= $default_version['minor']) {
$update_data = call_user_func($update['callback']);
$controller = array_merge($controller, $update_data);
}
}
}
}