SectionComponentBuildRenderArrayEvent example


  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;
  }

  /** * Gets any arbitrary property for the component. * * @param string $property * The property to retrieve. * * @return mixed * The value for that property, or NULL if the property does not exist. */
$block->getPreviewFallbackString()->willReturn($placeholder_label);

    $block_content = [
      '#markup' => 'The block content.',
      '#cache' => ['tags' => ['build-tag']],
    ];
    $block->build()->willReturn($block_content);
    $this->blockManager->createInstance('some_block_id', ['id' => 'some_block_id'])->willReturn($block->reveal());

    $component = new SectionComponent('some-uuid', 'some-region', ['id' => 'some_block_id']);
    $in_preview = FALSE;
    $event = new SectionComponentBuildRenderArrayEvent($component$contexts$in_preview);

    $subscriber = new BlockComponentRenderArray($this->account->reveal());

    $expected_build = [
      '#theme' => 'block',
      '#weight' => 0,
      '#configuration' => [],
      '#plugin_id' => 'block_plugin_id',
      '#base_plugin_id' => 'block_plugin_id',
      '#derivative_plugin_id' => NULL,
      'content' => $block_content,
      
Home | Imprint | This part of the site doesn't use cookies.