foreach ($children as $key) { if (isset($build_list[$key][$entity_type_key])) { $entity =
$build_list[$key][$entity_type_key];
if ($entity instanceof FieldableEntityInterface
) { $view_modes[$build_list[$key]['#view_mode'
]][$key] =
$entity;
} } } // Build content for the displays represented by the entities.
foreach ($view_modes as $view_mode =>
$view_mode_entities) { $displays = EntityViewDisplay::
collectRenderDisplays($view_mode_entities,
$view_mode);
$this->
buildComponents($build_list,
$view_mode_entities,
$displays,
$view_mode);
foreach (array_keys($view_mode_entities) as $key) { // Allow for alterations while building, before rendering.
$entity =
$build_list[$key][$entity_type_key];
$display =
$displays[$entity->
bundle()];
$this->
moduleHandler()->
invokeAll($view_hook,
[&
$build_list[$key],
$entity,
$display,
$view_mode]);
$this->
moduleHandler()->
invokeAll('entity_view',
[&
$build_list[$key],
$entity,
$display,
$view_mode]);
$this->
addContextualLinks($build_list[$key],
$entity);
$this->
alterBuild($build_list[$key],
$entity,
$display,
$view_mode);