function services_get_all in Services 6.2
Same name and namespace in other branches
- 5 services.module \services_get_all()
- 6 services.module \services_get_all()
- 7 services.module \services_get_all()
Get all service definitions
Parameters
bool $include_resources: Optional. When TRUE resource-based service definitions will be translated to the appropriate method calls 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 - Page callback to list all enabled services and servers.
- services_get_all_resources in ./
services.module - Gets all resource definitions.
- services_keyauth_admin_keys_form in auth/
services_keyauth/ services_keyauth.admin.inc - Display the form to create or edit API keys.
- services_method_get in ./
services.module - Get the definition of a method.
- services_system_modules_submit in ./
services.module - Submit handler for the system_modules form that clears the services cache.
File
- ./
services.module, line 685 - Provides a generic but powerful API for exposing web services.
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)) {
// This code is copied from this D7 patch http://drupal.org/node/718636
// and is required because under certain caching circumstances, cache_get
// does not unserialize the data it returns.
if (!is_array($cache->data)) {
$cache->data = unserialize($cache->data);
}
return $cache->data;
}
else {
$methods = module_invoke_all('service');
services_strip_hashes($methods);
foreach ($methods as $key => $method) {
if (!isset($methods[$key]['access callback'])) {
$methods[$key]['access callback'] = 'user_access';
}
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;
}
}