You are here

protected function Panelizer::setCacheTags in Panelizer 8.5

Same name and namespace in other branches
  1. 8.3 src/Panelizer.php \Drupal\panelizer\Panelizer::setCacheTags()
  2. 8.4 src/Panelizer.php \Drupal\panelizer\Panelizer::setCacheTags()

Properly determine the cache tags for a display and set them.

Parameters

\Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display: The panels display variant.

string $entity_type_id: The entity type id.

string $bundle: The bundle.

string $view_mode: The view mode.

\Drupal\Core\Entity\Display\EntityViewDisplayInterface|NULL $display: If the caller already has the correct display, it can optionally be passed in here so the Panelizer service doesn't have to look it up; otherwise, this argument can be omitted.

$default: The name of the panels display we are about to render.

array $settings: The default panelizer settings for this EntityViewDisplay.

1 call to Panelizer::setCacheTags()
Panelizer::getPanelsDisplay in src/Panelizer.php
Gets the Panels display for a given entity and view mode.

File

src/Panelizer.php, line 273

Class

Panelizer
The Panelizer service.

Namespace

Drupal\panelizer

Code

protected function setCacheTags(PanelsDisplayVariant $panels_display, $entity_type_id, $bundle, $view_mode, EntityViewDisplayInterface $display = NULL, $default, array $settings) {
  if (!$display) {
    $display = $this
      ->getEntityViewDisplay($entity_type_id, $bundle, $view_mode);
  }
  $display_mode = $display ? $display
    ->getMode() : '';
  if ($default == $settings['default']) {
    $tags = [
      "{$panels_display->getStorageType()}:{$entity_type_id}:{$bundle}:{$display_mode}",
    ];
  }
  $tags[] = "{$panels_display->getStorageType()}:{$entity_type_id}:{$bundle}:{$display_mode}:{$default}";
  $panels_display
    ->addCacheTags($tags);
}