You are here

public function DatasourcePluginBase::getItemLanguage in Search API 8

Retrieves the item's language.

Parameters

\Drupal\Core\TypedData\ComplexDataInterface $item: An item of this datasource's type.

Return value

string The language code of this item.

Overrides DatasourceInterface::getItemLanguage

1 method overrides DatasourcePluginBase::getItemLanguage()
TestDatasource::getItemLanguage in tests/search_api_test/src/Plugin/search_api/datasource/TestDatasource.php
Retrieves the item's language.

File

src/Datasource/DatasourcePluginBase.php, line 80

Class

DatasourcePluginBase
Defines a base class from which other datasources may extend.

Namespace

Drupal\search_api\Datasource

Code

public function getItemLanguage(ComplexDataInterface $item) {
  if ($item instanceof TranslatableInterface) {
    return $item
      ->language()
      ->getId();
  }
  $item = $item
    ->getValue();
  if ($item instanceof TranslatableInterface) {
    return $item
      ->language()
      ->getId();
  }
  return Language::LANGCODE_NOT_SPECIFIED;
}