You are here

function acquia_search_search_api_server_load in Acquia Search 3.x

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

Implements hook_search_api_server_load().

Flag when a certain server should be enforcing read-only mode.

File

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

Code

function acquia_search_search_api_server_load(array $entities) {

  /** @var \Drupal\search_api\Entity\Server[] $entities */
  $acquia_servers = array_filter($entities, function ($server) {
    return Runtime::isAcquiaServer($server);
  });
  foreach ($acquia_servers as $server) {

    /** @var \Drupal\search_api\Entity\Server $server */
    $backend_config = $server
      ->getBackendConfig();
    unset($backend_config['overridden_by_acquia_search']);
    if (Runtime::shouldEnforceReadOnlyMode()) {
      $backend_config['overridden_by_acquia_search'] = SearchApiSolrAcquiaConnector::READ_ONLY;
    }
    $server
      ->setBackendConfig($backend_config);
  }
}