You are here

public function PanelizerEntityBase::preprocessViewMode in Panelizer 8.4

Same name and namespace in other branches
  1. 8.5 src/Plugin/PanelizerEntityBase.php \Drupal\panelizer\Plugin\PanelizerEntityBase::preprocessViewMode()
  2. 8.3 src/Plugin/PanelizerEntityBase.php \Drupal\panelizer\Plugin\PanelizerEntityBase::preprocessViewMode()

Preprocess the variables for the view mode template.

Parameters

array $variables: The variables to pass to the view mode template.

\Drupal\Core\Entity\EntityInterface $entity: The entity.

\Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display: The Panels display used to render this entity.

string $view_mode: The view mode.

Overrides PanelizerEntityInterface::preprocessViewMode

1 call to PanelizerEntityBase::preprocessViewMode()
PanelizerNode::preprocessViewMode in src/Plugin/PanelizerEntity/PanelizerNode.php
Preprocess the variables for the view mode template.
1 method overrides PanelizerEntityBase::preprocessViewMode()
PanelizerNode::preprocessViewMode in src/Plugin/PanelizerEntity/PanelizerNode.php
Preprocess the variables for the view mode template.

File

src/Plugin/PanelizerEntityBase.php, line 118

Class

PanelizerEntityBase
Base class for Panelizer entity plugins.

Namespace

Drupal\panelizer\Plugin

Code

public function preprocessViewMode(array &$variables, EntityInterface $entity, PanelsDisplayVariant $panels_display, $view_mode) {
  $entity_type_id = $this
    ->getPluginId();

  // Add some default classes.
  $variables['attributes']['class'][] = $entity_type_id;
  $variables['attributes']['class'][] = $entity_type_id . '--type-' . $entity
    ->bundle();
  $variables['attributes']['class'][] = $entity_type_id . '--view-mode-' . $view_mode;
  $variables['attributes']['class'][] = 'clearfix';

  // Don't render the title in the template
  if ($view_mode == 'full') {
    $variables['title'] = '';
  }
}