You are here

function acquia_search_preprocess_search_api_index in Acquia Search 3.x

Same name and namespace in other branches
  1. 2.x acquia_search.module \acquia_search_preprocess_search_api_index()

Implements hook_preprocess_HOOK().

Theme override for Search API index status page.

Throws

\Drupal\Component\Plugin\Exception\PluginException

\Drupal\search_api\SearchApiException

File

./acquia_search.module, line 282
Integration between Drupal and Acquia's hosted Solr search service.

Code

function acquia_search_preprocess_search_api_index(array &$variables) {

  /** @var \Drupal\search_api\Entity\Index $index */
  $index = $variables['index'];

  /** @var \Drupal\search_api\Entity\Server $server */
  $server = Server::load($index
    ->get('server'));
  if (!$server || !Runtime::isAcquiaServer($server)) {
    return;
  }
  if (Runtime::shouldEnforceReadOnlyMode()) {
    Messages::showReadOnlyModeWarning();
  }
  if (!Runtime::getPreferredSearchCoreService()
    ->isPreferredCoreAvailable()) {

    // Show "could not find preferred core" message.
    Messages::showNoPreferredCoreError();
  }
  $variables['acquia_search_info_box'] = [
    '#type' => 'fieldset',
    '#title' => t('Acquia Search status for this connection'),
    '#markup' => Messages::getSearchStatusMessage($server),
  ];
}