You are here

public function Section::toRenderArray in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Section.php \Drupal\layout_builder\Section::toRenderArray()

Returns the renderable array for this section.

Parameters

\Drupal\Core\Plugin\Context\ContextInterface[] $contexts: An array of available contexts.

bool $in_preview: TRUE if the section is being previewed, FALSE otherwise.

Return value

array A renderable array representing the content of the section.

File

core/modules/layout_builder/src/Section.php, line 83

Class

Section
Provides a domain object for layout sections.

Namespace

Drupal\layout_builder

Code

public function toRenderArray(array $contexts = [], $in_preview = FALSE) {
  $regions = [];
  foreach ($this
    ->getComponents() as $component) {
    if ($output = $component
      ->toRenderArray($contexts, $in_preview)) {
      $regions[$component
        ->getRegion()][$component
        ->getUuid()] = $output;
    }
  }
  return $this
    ->getLayout()
    ->build($regions);
}