You are here

protected function SearchApiSolrAcquiaConnector::connect in Acquia Search 3.x

Same name and namespace in other branches
  1. 2.x src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php \Drupal\acquia_search\Plugin\SolrConnector\SearchApiSolrAcquiaConnector::connect()

Prepares the connection to the Solr server.

Overrides SolrConnectorPluginBase::connect

4 calls to SearchApiSolrAcquiaConnector::connect()
SearchApiSolrAcquiaConnector::getExtractQuery in src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php
Creates a new Solarium extract query.
SearchApiSolrAcquiaConnector::getMoreLikeThisQuery in src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php
Creates a new Solarium more like this query.
SearchApiSolrAcquiaConnector::getServerUri in src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php
Returns a the Solr server URI.
SearchApiSolrAcquiaConnector::getUpdateQuery in src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php
Avoid providing an valid Update query if module determines this server should be locked down (as indicated by the overridden_by_acquia_search server option).

File

src/Plugin/SolrConnector/SearchApiSolrAcquiaConnector.php, line 318

Class

SearchApiSolrAcquiaConnector
Class SearchApiSolrAcquiaConnector.

Namespace

Drupal\acquia_search\Plugin\SolrConnector

Code

protected function connect() {
  if ($this->solr) {
    return;
  }

  // Create a PSR-18 adapter instance, since Solarium's HTTP adapter is
  // incompatible with remote_stream_wrapper.
  // See https://www.drupal.org/project/acquia_search/issues/3209704
  // And https://www.drupal.org/project/acquia_search_solr/issues/3171407
  $httpClient = new Guzzle6Client();
  $adapter = new TimeoutAwarePsr18Adapter($httpClient);
  $this->solr = new Client($adapter, $this->eventDispatcher);

  // Scheme should always be https and port 443.
  $this->configuration['scheme'] = 'https';
  $this->configuration['port'] = 443;
  $this->configuration['key'] = self::ENDPOINT_KEY;
  $this->configuration['path'] = '/';
  $this->configuration[self::QUERY_TIMEOUT] = $this->configuration['timeout'];
  $this->solr
    ->createEndpoint($this->configuration, TRUE);
  $this->solr
    ->registerPlugin('acquia_solr_search_subscriber', $this->searchSubscriber);
}