You are here

public static function SearchApiQuery::getIndexFromTable in Search API 8

Loads the search index belonging to the given Views base table.

Parameters

string $table: The Views base table ID.

\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: (optional) The entity type manager to use.

Return value

\Drupal\search_api\IndexInterface|null The requested search index, or NULL if it could not be found and loaded.

9 calls to SearchApiQuery::getIndexFromTable()
SearchApiDataRow::init in src/Plugin/views/row/SearchApiDataRow.php
Initialize the plugin.
SearchApiFulltext::getFulltextFields in src/Plugin/views/argument/SearchApiFulltext.php
Retrieves an options list of available fulltext fields.
SearchApiHandlerTrait::getIndex in src/Plugin/views/SearchApiHandlerTrait.php
Returns the active search index.
SearchApiQuery::init in src/Plugin/views/query/SearchApiQuery.php
Constructor; Create the basic query object and fill with default values.
SearchApiRenderedItem::init in src/Plugin/views/field/SearchApiRenderedItem.php
Overrides Drupal\views\Plugin\views\HandlerBase::init().

... See full list

File

src/Plugin/views/query/SearchApiQuery.php, line 152

Class

SearchApiQuery
Defines a Views query class for searching on Search API indexes.

Namespace

Drupal\search_api\Plugin\views\query

Code

public static function getIndexFromTable($table, EntityTypeManagerInterface $entity_type_manager = NULL) {

  // @todo Instead use Views::viewsData() – injected, too – to load the base
  //   table definition and use the "index" (or maybe rename to
  //   "search_api_index") field from there.
  if (substr($table, 0, 17) == 'search_api_index_') {
    $index_id = substr($table, 17);
    if ($entity_type_manager) {
      return $entity_type_manager
        ->getStorage('search_api_index')
        ->load($index_id);
    }
    return Index::load($index_id);
  }
  return NULL;
}