function _services_apply_endpoint in Services 6.3
Same name and namespace in other branches
- 7.3 includes/services.resource_build.inc \_services_apply_endpoint()
Applies the endpoint to a set of resources. Resources and controllers that aren't supported will be removed (if $strict is set to TRUE) and both resources and controllers will get the 'endpoint' attribute set.
Parameters
array $resources: An array of resources that the endpoint should be applied on.
array $endpoint: A endpoint information array.
bool $strict: Optional.
Return value
void
2 calls to _services_apply_endpoint()
- services_edit_form_endpoint_resources in plugins/
export_ui/ services_ctools_export_ui.class.php - services_edit_form_endpoint_resources function.
- _services_build_resources in ./
services.resource_build.inc - Builds the resource definition array for a endpoint.
File
- ./
services.resource_build.inc, line 151 - Contains functions necessary for building the resource definitions. This is only needed the first time a the resources for a endpoint are fetched, or when the cache has been cleared.
Code
function _services_apply_endpoint(&$resources, $endpoint, $strict = TRUE) {
if (is_array($endpoint) && isset($endpoint['build_info'])) {
$endpoint = $endpoint['build_info']['args'][0];
}
$classes = array_keys(services_operation_class_info());
foreach ($resources as $name => &$resource) {
$cres = $endpoint && isset($endpoint->resources[$name]) ? $endpoint->resources[$name] : array();
$resource['endpoint'] = $cres;
if ($strict && empty($cres)) {
unset($resources[$name]);
}
else {
foreach ($classes as $class) {
if (!empty($resource[$class])) {
foreach ($resource[$class] as $op => $def) {
$cop = isset($cres[$class][$op]) ? $cres[$class][$op] : array();
if (empty($cop) || !$cop['enabled']) {
if ($strict) {
unset($resource[$class][$op]);
}
}
else {
$resource[$class][$op]['endpoint'] = empty($cop['settings']) ? array() : $cop['settings'];
}
}
}
}
}
}
}