You are here

public function ContentEntity::getViewModes in Search API 8

Returns the available view modes for this datasource.

Parameters

string|null $bundle: (optional) The bundle for which to return the available view modes. Or NULL to return all view modes for this datasource, across all bundles.

Return value

string[] An associative array of view mode labels, keyed by the view mode ID. Can be empty if it isn't possible to view items of this datasource.

Overrides DatasourcePluginBase::getViewModes

File

src/Plugin/search_api/datasource/ContentEntity.php, line 991

Class

ContentEntity
Represents a datasource which exposes the content entities.

Namespace

Drupal\search_api\Plugin\search_api\datasource

Code

public function getViewModes($bundle = NULL) {
  return $this
    ->getEntityDisplayRepository()
    ->getViewModeOptions($this
    ->getEntityTypeId());
}