public function Section::toRenderArray in Drupal 9
Same name and namespace in other branches
- 8 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_builderCode
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($contexts)
->build($regions);
}