You are here

function acquia_search_form_search_api_server_status_alter in Acquia Search 3.x

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

Implements hook_form_FORM_ID_alter().

Alters the Search API server's status form and displays a warning.

File

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

Code

function acquia_search_form_search_api_server_status_alter(&$form) {
  if (empty($form['#server'])) {
    return;
  }
  $server = $form['#server'];
  if (!is_object($server) || get_class($server) !== Server::class) {
    return;
  }

  /** @var \Drupal\search_api\Entity\Server $server */
  if (!Runtime::isAcquiaServer($server)) {
    return;
  }
  if (Runtime::shouldEnforceReadOnlyMode()) {

    // Show read-only warning and disable the "Delete all indexed data on this
    // server" action.
    Messages::showReadOnlyModeWarning();
    $form['actions']['clear']['#disabled'] = TRUE;
  }
  if (!Runtime::getPreferredSearchCoreService()
    ->isPreferredCoreAvailable()) {

    // Show "could not find preferred core" message.
    Messages::showNoPreferredCoreError();
  }
}