You are here

function search_api_db_defaults_requirements in Search API 8

Implements hook_requirements().

File

modules/search_api_db/search_api_db_defaults/search_api_db_defaults.install, line 13
Install, update and uninstall functions for the DB Search Defaults module.

Code

function search_api_db_defaults_requirements($phase) {
  $requirements = [];
  if ($phase == 'install') {

    // In case this is installed at the same time as the Search API module
    // itself, the class autoloader will not be able to find the
    // \Drupal\search_api\IndexListBuilder class on its own. Load it manually.
    if (!class_exists(IndexListBuilder::class)) {
      $search_api_path = drupal_get_path('module', 'search_api');
      require_once $search_api_path . '/src/IndexListBuilder.php';
    }
    $errors = IndexListBuilder::checkDefaultsModuleCanBeInstalled();
    foreach ($errors as $type => $error) {
      $requirements["search_api_db_defaults:{$type}"] = [
        'severity' => REQUIREMENT_ERROR,
        'description' => $error,
      ];
    }
  }
  return $requirements;
}