You are here

public function ViewMode::getViewMode in Search API Pages 8

Gets the configured view mode for a given data source and bundle.

Parameters

string $dataSourceId: The data source id.

string $bundleId: The bundle id.

Return value

string The view mode machine name.

Overrides ViewModeConfigInterface::getViewMode

File

src/Config/ViewMode.php, line 30

Class

ViewMode
Value object for view mode configuration.

Namespace

Drupal\search_api_page\Config

Code

public function getViewMode($dataSourceId, $bundleId) {
  if (!isset($this->rawConfig[$dataSourceId])) {
    return self::DEFAULT_VIEW_MODE;
  }
  if (!$this
    ->hasOverrides($dataSourceId)) {
    return $this
      ->getDefaultViewMode($dataSourceId);
  }
  if (!$this
    ->isOverridden($dataSourceId, $bundleId)) {
    return $this
      ->getDefaultViewMode($dataSourceId);
  }
  return $this->rawConfig[$dataSourceId]['overrides'][$bundleId];
}