diff --git a/search_api.install b/search_api.install index 88a8f6c..7993da6 100644 --- a/search_api.install +++ b/search_api.install @@ -4,6 +4,7 @@ * @file * Install, update and uninstall functions for the Search API module. */ +use Drupal\search_api\Entity\Server; /** * Implements hook_schema(). @@ -106,9 +107,10 @@ function search_api_install() { */ function search_api_requirements($phase) { if ($phase == 'runtime') { + $requirements = array(); $message = _search_api_search_module_warning(); if ($message) { - return array( + $requirements += array( 'search_api_core_search' => array( 'title' => t('Search API'), 'value' => $message, @@ -116,6 +118,25 @@ function search_api_requirements($phase) { ), ); } + $servers = Server::loadMultiple(); + $unavailable_servers = array(); + foreach ($servers as $server) { + if (!$server->isAvailable()) { + $unavailable_servers[] = $server->label(); + } + } + if (!empty($unavailable_servers)) { + $requirements += array( + 'search_api_server_unavailable' => array( + 'title' => t('Search API'), + 'value' => t('The servers: @servers are down.', array('@servers' => implode(',', $unavailable_servers))), + 'severity' => REQUIREMENT_ERROR + ) + ); + + } + + return $requirements; } return array(); } diff --git a/src/IndexListBuilder.php b/src/IndexListBuilder.php index 7992f97..3bed36a 100644 --- a/src/IndexListBuilder.php +++ b/src/IndexListBuilder.php @@ -99,10 +99,15 @@ class IndexListBuilder extends ConfigEntityListBuilder { /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */ $row = parent::buildRow($entity); - $status_label = $entity->status() ? $this->t('Enabled') : $this->t('Disabled'); + $status = $entity->status(); + if ($entity instanceof ServerInterface && !$entity->isAvailable()) { + $status = FALSE; + } + + $status_label = $status ? $this->t('Enabled') : $this->t('Disabled'); $status_icon = array( '#theme' => 'image', - '#uri' => $entity->status() ? 'core/misc/icons/73b355/check.svg' : 'core/misc/icons/e32700/error.svg', + '#uri' => $status ? 'core/misc/icons/73b355/check.svg' : 'core/misc/icons/e32700/error.svg', '#width' => 18, '#height' => 18, '#alt' => $status_label, @@ -132,8 +137,9 @@ class IndexListBuilder extends ConfigEntityListBuilder { 'title' => $this->t('ID: @name', array('@name' => $entity->id())), 'class' => array( Html::cleanCssIdentifier($entity->getEntityTypeId() . '-' . $entity->id()), - $entity->status() ? 'search-api-list-enabled' : 'search-api-list-disabled', + $status ? 'search-api-list-enabled' : 'search-api-list-disabled', $entity instanceof ServerInterface ? 'search-api-list-server' : 'search-api-list-index', + $entity instanceof ServerInterface && !$entity->isAvailable() ? 'color-error' : '', ), ); }