function services_get_all in Services 7
Same name and namespace in other branches
- 5 services.module \services_get_all()
- 6 services.module \services_get_all()
- 6.2 services.module \services_get_all()
Gets all service definitions
Parameters
bool $include_resources: Optional. When TRUE resource-based service definitions will be translated to the appropriat method callas and included in the service listing. Defaults to TRUE.
Return value
array An array containing all services and thir methods
7 calls to services_get_all()
- services_admin_browse_index in ./
services_admin_browse.inc - Callback for 'services/browse'.
- services_get_all_resources in ./
services.module - Gets all resource definitions.
- services_keyauth_admin_keys_form in auth/
services_keyauth/ services_keyauth.admin.inc - services_method_get in ./
services.module - services_system_modules_submit in ./
services.module
File
- ./
services.module, line 529 - @author Services Dev Team
Code
function services_get_all($include_resources = TRUE, $reset = FALSE) {
$cache_key = 'services:methods' . ($include_resources ? '_with_resources' : '');
if (!$reset && ($cache = cache_get($cache_key)) && isset($cache->data)) {
return $cache->data;
}
else {
$methods = module_invoke_all('service');
foreach ($methods as $key => $method) {
if (!isset($methods[$key]['#access callback'])) {
$methods[$key]['#access callback'] = 'services_access_menu';
}
if (!isset($methods[$key]['#args'])) {
$methods[$key]['#args'] = array();
}
// set defaults for args
foreach ($methods[$key]['#args'] as $arg_key => $arg) {
if (is_array($arg)) {
if (!isset($arg['#optional'])) {
$methods[$key]['#args'][$arg_key]['#optional'] = FALSE;
}
}
else {
$arr_arg = array();
$arr_arg['#name'] = t('unnamed');
$arr_arg['#type'] = $arg;
$arr_arg['#description'] = t('No description given.');
$arr_arg['#optional'] = FALSE;
$methods[$key]['#args'][$arg_key] = $arr_arg;
}
}
reset($methods[$key]['#args']);
}
// Allow auth module to alter the methods
services_auth_invoke('alter_methods', $methods);
// Add resources if wanted
if ($include_resources) {
$resources = services_get_all_resources(FALSE, $reset);
// Include the file that has the necessary functions for translating
// resources to method calls.
if (!empty($resources)) {
module_load_include('inc', 'services', 'services.resource-translation');
// Translate all resources
foreach ($resources as $name => $def) {
foreach (_services_resource_as_services($def) as $method) {
$methods[] = $method;
}
}
}
}
cache_set($cache_key, $methods);
return $methods;
}
}