You are here

protected function PanelizerEntityViewBuilder::buildMultiplePanelized in Panelizer 8.5

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

Build the render array for a list of panelized entities.

Parameters

\Drupal\Core\Entity\EntityInterface[] $entities:

\Drupal\Core\Entity\Display\EntityViewDisplayInterface[] $displays:

string $view_mode:

string|NULL $langcode:

Return value

array

2 calls to PanelizerEntityViewBuilder::buildMultiplePanelized()
PanelizerEntityViewBuilder::view in src/PanelizerEntityViewBuilder.php
Builds the render array for the provided entity.
PanelizerEntityViewBuilder::viewMultiple in src/PanelizerEntityViewBuilder.php
Builds the render array for the provided entities.

File

src/PanelizerEntityViewBuilder.php, line 348

Class

PanelizerEntityViewBuilder
Entity view builder for entities that can be panelized.

Namespace

Drupal\panelizer

Code

protected function buildMultiplePanelized(array $entities, array $displays, $view_mode, $langcode) {
  $build = [];
  foreach ($entities as $id => $entity) {
    $panels_display = $this->panelizer
      ->getPanelsDisplay($entity, $view_mode, $displays[$entity
      ->bundle()]);
    $settings = $this->panelizer
      ->getPanelizerSettings($entity
      ->getEntityTypeId(), $entity
      ->bundle(), $view_mode, $displays[$entity
      ->bundle()]);
    $panels_display
      ->setContexts($this->panelizer
      ->getDisplayStaticContexts($settings['default'], $entity
      ->getEntityTypeId(), $entity
      ->bundle(), $view_mode, $displays[$entity
      ->bundle()]));
    $build[$id] = $this
      ->buildPanelized($entity, $panels_display, $view_mode, $langcode);

    // Allow modules to modify the render array.
    $alter_types = [
      "{$this->entityTypeId}_view",
      'entity_view',
    ];
    $this->moduleHandler
      ->alter($alter_types, $build[$id], $entity, $displays[$entity
      ->bundle()]);
  }
  return $build;
}