You are here

public function PanelizerEntityDefault::get_view_mode in Panelizer 7.3

Identify the view mode that will actually be used for a specific request.

Parameters

string $view_mode: The original view mode to be checked.

string $bundle: The entity bundle being used.

Return value

string The final view mode that will be used.

Overrides PanelizerEntityInterface::get_view_mode

File

plugins/entity/PanelizerEntityDefault.class.php, line 792
Base class for the Panelizer Entity plugin.

Class

PanelizerEntityDefault
Base class for the Panelizer Entity plugin.

Code

public function get_view_mode($view_mode, $bundle) {
  $settings = !empty($this->plugin['bundles'][$bundle]) ? $this->plugin['bundles'][$bundle] : array(
    'status' => FALSE,
    'choice' => FALSE,
  );

  // Test to see if this view mode is actually panelizable at all.
  if (!isset($this->plugin['view modes'][$view_mode]) || empty($this->plugin['view modes'][$view_mode]['custom settings']) && empty($this->plugin['view mode status'][$bundle][$view_mode])) {
    $view_mode = 'default';
  }

  // See if a substitute should be used.
  $substitute = $this
    ->get_substitute($view_mode, $bundle);
  if (!empty($substitute)) {
    $view_mode = $substitute;
  }
  return $view_mode;
}