You are here

public function BlockComponentRenderArraySubscriber::onBuildRender in Layout Builder Blocks 1.0.x

Add each component's block styles to the render array.

Parameters

\Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent $event: The section component render event.

File

src/EventSubscriber/BlockComponentRenderArraySubscriber.php, line 61

Class

BlockComponentRenderArraySubscriber
Class BlockComponentRenderArraySubscriber.

Namespace

Drupal\layout_builder_blocks\EventSubscriber

Code

public function onBuildRender(SectionComponentBuildRenderArrayEvent $event) {
  $build = $event
    ->getBuild();
  $block_style_configs = [];
  if ($bootstrap_styles = $event
    ->getComponent()
    ->get('bootstrap_styles')) {
    if (isset($bootstrap_styles['block_style'])) {
      $block_style_configs = $bootstrap_styles['block_style'];
    }
  }

  // Build dynamic styles.
  if (count($block_style_configs) > 0) {
    $build = $this->stylesGroupManager
      ->buildStyles($build, $block_style_configs, NULL);
  }
  $event
    ->setBuild($build);
}