You are here

function search_api_get_item_type_info in Search API 7

Returns information for either all item types, or a specific one.

Parameters

string|null $type: If set, the item type whose information should be returned.

Return value

array|null If $type is given, either an array containing the information of that item type, or NULL if it is unknown. Otherwise, an array keyed by type IDs containing the information for all item types. Item type information is formatted as specified by hook_search_api_item_type_info(), with the addition of a "module" key specifying the module that adds a certain type.

See also

hook_search_api_item_type_info()

9 calls to search_api_get_item_type_info()
drush_search_api_list in ./search_api.drush.inc
List all search indexes.
SearchApiAbstractDataSourceController::checkIndex in includes/datasource.inc
Checks whether the given index is valid for this datasource controller.
SearchApiAbstractDataSourceController::__construct in includes/datasource.inc
Constructs an SearchApiDataSourceControllerInterface object.
search_api_admin_add_index in ./search_api.admin.inc
Form constructor for adding an index.
search_api_get_datasource_controller in ./search_api.module
Get a data source controller object for the specified type.

... See full list

2 string references to 'search_api_get_item_type_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 2084
Provides a flexible framework for implementing search services.

Code

function search_api_get_item_type_info($type = NULL) {
  $types =& drupal_static(__FUNCTION__);
  if (!isset($types)) {

    // Inlined version of module_invoke_all() to add "module" keys.
    $types = array();
    foreach (module_implements('search_api_item_type_info') as $module) {
      $function = $module . '_search_api_item_type_info';
      if (function_exists($function)) {
        $new_types = $function();
        if (isset($new_types) && is_array($new_types)) {
          foreach ($new_types as $id => $info) {
            $new_types[$id] += array(
              'module' => $module,
            );
          }
        }
        $types += $new_types;
      }
    }

    // Same for drupal_alter().
    foreach (module_implements('search_api_item_type_info_alter') as $module) {
      $function = $module . '_search_api_item_type_info_alter';
      if (function_exists($function)) {
        $old = $types;
        $function($types);
        if ($new_types = array_diff_key($types, $old)) {
          foreach ($new_types as $id => $info) {
            $types[$id] += array(
              'module' => $module,
            );
          }
        }
      }
    }
  }
  if (isset($type)) {
    return isset($types[$type]) ? $types[$type] : NULL;
  }
  return $types;
}