You are here

function services_get_all_resources in Services 7

Same name and namespace in other branches
  1. 6.2 services.module \services_get_all_resources()

Gets all resource definitions.

Return value

array An array containing all resources.

1 call to services_get_all_resources()
services_get_all in ./services.module
Gets all service definitions

File

./services.module, line 395
@author Services Dev Team

Code

function services_get_all_resources($include_services = TRUE, $reset = FALSE) {
  $cache_key = 'services:resources' . ($include_services ? '_with_services' : '');
  if (!$reset && ($cache = cache_get($cache_key)) && isset($cache->data)) {
    return $cache->data;
  }
  else {
    $resources = module_invoke_all('service_resource');
    drupal_alter('service_resources', $resources);
    $controllers = array();
    services_process_resources($resources, $controllers);
    foreach ($controllers as &$controller) {
      if (!isset($controller['#access callback'])) {
        $controller['#access callback'] = 'services_access_menu';
      }
      if (!isset($controller['#auth'])) {
        $controller['#auth'] = TRUE;
      }
      if (!isset($controller['#key'])) {
        $controller['#key'] = TRUE;
      }
    }
    drupal_alter('service_resources_post_processing', $resources);
    services_auth_invoke('alter_methods', $controllers);
    if ($include_services) {
      $services = services_get_all(FALSE);

      // Include the file that has the necessary functions for translating
      // methods to resources.
      if (!empty($services)) {
        module_load_include('inc', 'services', 'services.resource-translation');
        $resources = array_merge(_services_services_as_resources($services), $resources);
      }
    }
    cache_set($cache_key, $resources);
    return $resources;
  }
}