You are here

public function Index::getFieldsByDatasource in Search API 8

Returns a list of all indexed fields of a specific datasource.

Parameters

string|null $datasource_id: The ID of the datasource whose fields should be retrieved, or NULL to retrieve all datasource-independent fields.

Return value

\Drupal\search_api\Item\FieldInterface[] An array of all indexed fields for the given datasource, keyed by field identifier.

Overrides IndexInterface::getFieldsByDatasource

1 call to Index::getFieldsByDatasource()
Index::getFieldDependencies in src/Entity/Index.php
Retrieves information about the dependencies of the indexed fields.

File

src/Entity/Index.php, line 782

Class

Index
Defines the search index configuration entity.

Namespace

Drupal\search_api\Entity

Code

public function getFieldsByDatasource($datasource_id) {
  $datasource_fields = [];
  foreach ($this
    ->getFields() as $field_id => $field) {
    if ($field
      ->getDatasourceId() === $datasource_id) {
      $datasource_fields[$field_id] = $field;
    }
  }
  return $datasource_fields;
}