public function PanelizerEntityViewBuilder::buildComponents in Panelizer 8.4
Same name and namespace in other branches
- 8.5 src/PanelizerEntityViewBuilder.php \Drupal\panelizer\PanelizerEntityViewBuilder::buildComponents()
- 8.3 src/PanelizerEntityViewBuilder.php \Drupal\panelizer\PanelizerEntityViewBuilder::buildComponents()
Builds the component fields and properties of a set of entities.
Parameters
&$build: The renderable array representing the entity content.
\Drupal\Core\Entity\EntityInterface[] $entities: The entities whose content is being built.
\Drupal\Core\Entity\Display\EntityViewDisplayInterface[] $displays: The array of entity view displays holding the display options configured for the entity components, keyed by bundle name.
string $view_mode: The view mode in which the entity is being viewed.
Overrides EntityViewBuilderInterface::buildComponents
File
- src/
PanelizerEntityViewBuilder.php, line 223
Class
- PanelizerEntityViewBuilder
- Entity view builder for entities that can be panelized.
Namespace
Drupal\panelizerCode
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
$fallback_view_builder = $this
->getFallbackViewBuilder();
$panelized_entities = [];
$fallback_entities = [];
/**
* @var string $id
* @var \Drupal\Core\Entity\EntityInterface $entity
*/
foreach ($entities as $id => $entity) {
$display = $displays[$entity
->bundle()];
if ($this
->isPanelizerEnabled($display)) {
$panelized_entities[$id] = $entity;
}
else {
$fallback_entities[$id] = $entity;
}
}
// Handle all the fallback entities first!
if (!empty($fallback_entities)) {
$fallback_view_builder
->buildComponents($build, $fallback_entities, $displays, $view_mode);
}
// Handle the panelized entities.
if (!empty($panelized_entities)) {
$this->moduleHandler
->invokeAll('entity_prepare_view', [
$this->entityTypeId,
$panelized_entities,
$displays,
$view_mode,
]);
}
}