You are here

function search_api_get_service_info in Search API 7

Returns either a list of all available service infos, or a specific one.

Parameters

string|null $id: The ID of the service info to retrieve.

Return value

array If $id was not specified, an array of all available service classes. Otherwise, either the service info with the specified id (if it exists), or NULL. Service class information is formatted as specified by hook_search_api_service_info(), with the addition of a "module" key specifying the module that adds a certain class.

See also

hook_search_api_service_info()

8 calls to search_api_get_service_info()
SearchApiServer::ensureProxy in includes/server_entity.inc
Helper method for ensuring the proxy object is set up.
SearchApiViewsHandlerArgumentMoreLikeThis::query in contrib/search_api_views/includes/handler_argument_more_like_this.inc
Set up the query for this argument.
search_api_admin_add_server in ./search_api.admin.inc
Form callback showing a form for adding a server.
search_api_admin_add_server_validate in ./search_api.admin.inc
Form validation handler for adding a server.
search_api_admin_server_edit in ./search_api.admin.inc
Form constructor for editing a server's settings.

... See full list

2 string references to 'search_api_get_service_info'
search_api_modules_disabled in ./search_api.module
Implements hook_modules_disabled().
search_api_modules_enabled in ./search_api.module
Implements hook_modules_enabled().

File

./search_api.module, line 2029
Provides a flexible framework for implementing search services.

Code

function search_api_get_service_info($id = NULL) {
  $services =& drupal_static(__FUNCTION__);
  if (!isset($services)) {

    // Inlined version of module_invoke_all() to add "module" keys.
    $services = array();
    foreach (module_implements('search_api_service_info') as $module) {
      $function = $module . '_search_api_service_info';
      if (function_exists($function)) {
        $new_services = $function();
        if (isset($new_services) && is_array($new_services)) {
          foreach ($new_services as $service => $info) {
            $new_services[$service] += array(
              'module' => $module,
            );
          }
        }
        $services += $new_services;
      }
    }

    // Same for drupal_alter().
    foreach (module_implements('search_api_service_info_alter') as $module) {
      $function = $module . '_search_api_service_info_alter';
      if (function_exists($function)) {
        $old = $services;
        $function($services);
        if ($new_services = array_diff_key($services, $old)) {
          foreach ($new_services as $service => $info) {
            $services[$service] += array(
              'module' => $module,
            );
          }
        }
      }
    }
  }
  if (isset($id)) {
    return isset($services[$id]) ? $services[$id] : NULL;
  }
  return $services;
}