buildSections example


  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]);
          }
        }
      }
Home | Imprint | This part of the site doesn't use cookies.