You are here

private function DefaultSubscriber::loadIndexFromIndexName in Elasticsearch Connector Autocomplete 8

Loads the index entity associated with this event.

Parameters

string $index_name: The long index name as a string.

Return value

\Drupal\Core\Entity\EntityInterface|null The loaded index or NULL.

2 calls to DefaultSubscriber::loadIndexFromIndexName()
DefaultSubscriber::elasticsearchConnectorPrepareIndex in src/EventSubscriber/DefaultSubscriber.php
Called on elasticsearch_connector.prepare_index event.
DefaultSubscriber::elasticsearchConnectorPrepareIndexMapping in src/EventSubscriber/DefaultSubscriber.php
Called on elasticsearch_connector.prepare_index_mapping event.

File

src/EventSubscriber/DefaultSubscriber.php, line 157

Class

DefaultSubscriber
Class DefaultSubscriber.

Namespace

Drupal\elasticsearch_connector_autocomp\EventSubscriber

Code

private function loadIndexFromIndexName($index_name) {
  $index_storage = $this->entityTypeManager
    ->getStorage('search_api_index');

  /** @var \Drupal\search_api\Entity\Index[] $search_api_indexes */
  $search_api_indexes = $index_storage
    ->loadMultiple();
  foreach ($search_api_indexes as $search_api_index) {
    $elasticsearch_connector_index_name = IndexFactory::getIndexName($search_api_index);
    if ($index_name == $elasticsearch_connector_index_name) {
      return $search_api_index;
    }
  }
  return NULL;
}