Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LayoutBuilderEntityViewDisplay.php

function LayoutBuilderEntityViewDisplay::buildMultiple

Overrides EntityViewDisplay::buildMultiple

File

core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php, line 285

Class

LayoutBuilderEntityViewDisplay
Provides an entity view display entity that has a layout.

Namespace

Drupal\layout_builder\Entity

Code

public function buildMultiple(array $entities) {
    $build_list = parent::buildMultiple($entities);
    // Layout Builder can not be enabled for the '_custom' view mode that is
    // used for on-the-fly rendering of fields in isolation from the entity.
    if ($this->isCustomMode()) {
        return $build_list;
    }
    foreach ($entities as $id => $entity) {
        $build_list[$id]['_layout_builder'] = $this->buildSections($entity);
        // If there are any sections, remove all fields with configurable display
        // from the existing build. These fields are replicated within sections as
        // field blocks by ::setComponent().
        if (!Element::isEmpty($build_list[$id]['_layout_builder'])) {
            foreach ($build_list[$id] as $name => $build_part) {
                $field_definition = $this->getFieldDefinition($name);
                if ($field_definition && $field_definition->isDisplayConfigurable($this->displayContext)) {
                    unset($build_list[$id][$name]);
                }
            }
        }
    }
    return $build_list;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal