You are here

public function SectionComponentBuildRenderArrayEvent::__construct in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/Event/SectionComponentBuildRenderArrayEvent.php \Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent::__construct()
  2. 9 core/modules/layout_builder/src/Event/SectionComponentBuildRenderArrayEvent.php \Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent::__construct()

Creates a new SectionComponentBuildRenderArrayEvent object.

Parameters

\Drupal\layout_builder\SectionComponent $component: The section component whose render array is being built.

\Drupal\Core\Plugin\Context\ContextInterface[] $contexts: The available contexts.

bool $in_preview: (optional) Whether the component is in preview mode or not.

File

core/modules/layout_builder/src/Event/SectionComponentBuildRenderArrayEvent.php, line 67

Class

SectionComponentBuildRenderArrayEvent
Event fired when a section component's render array is being built.

Namespace

Drupal\layout_builder\Event

Code

public function __construct(SectionComponent $component, array $contexts, $in_preview = FALSE) {
  $this->component = $component;
  $this->contexts = $contexts;
  $this->plugin = $component
    ->getPlugin($contexts);
  $this->inPreview = $in_preview;
  if ($this->plugin instanceof PreviewAwarePluginInterface) {
    $this->plugin
      ->setInPreview($in_preview);
  }
}