You are here

public function SectionComponent::toRenderArray in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/SectionComponent.php \Drupal\layout_builder\SectionComponent::toRenderArray()
  2. 10 core/modules/layout_builder/src/SectionComponent.php \Drupal\layout_builder\SectionComponent::toRenderArray()

Returns the renderable array for this component.

Parameters

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

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

Return value

array A renderable array representing the content of the component.

File

core/modules/layout_builder/src/SectionComponent.php, line 88

Class

SectionComponent
Provides a value object for a section component.

Namespace

Drupal\layout_builder

Code

public function toRenderArray(array $contexts = [], $in_preview = FALSE) {
  $event = new SectionComponentBuildRenderArrayEvent($this, $contexts, $in_preview);
  $this
    ->eventDispatcher()
    ->dispatch($event, LayoutBuilderEvents::SECTION_COMPONENT_BUILD_RENDER_ARRAY);
  $output = $event
    ->getBuild();
  $event
    ->getCacheableMetadata()
    ->applyTo($output);
  return $output;
}