You are here

function search_api_features_export_alter in Search API 7

Implements hook_features_export_alter().

Adds dependency information for exported servers.

File

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

Code

function search_api_features_export_alter(&$export) {
  if (isset($export['features']['search_api_server'])) {

    // Get a list of the modules that provide storage engines.
    $hook = 'search_api_service_info';
    $classes = array();
    foreach (module_implements('search_api_service_info') as $module) {
      $function = $module . '_' . $hook;
      $engines = $function();
      foreach ($engines as $service => $specs) {
        $classes[$service] = $module;
      }
    }

    // Check all of the exported server specifications.
    foreach ($export['features']['search_api_server'] as $server_name) {

      // Load the server's object.
      $server = search_api_server_load($server_name);
      $module = $classes[$server->class];

      // Ensure that the module responsible for the server object is listed as
      // a dependency.
      if (!isset($export['dependencies'][$module])) {
        $export['dependencies'][$module] = $module;
      }
    }

    // Ensure the dependencies list is still sorted alphabetically.
    ksort($export['dependencies']);
  }
}