public function BaseLayoutBase::build in Layout Builder Base 8
Build a render array for layout with regions.
Parameters
array $regions: An associative array keyed by region name, containing render arrays representing the content that should be placed in each region.
Return value
array Render array for the layout with regions.
Overrides MultiWidthLayoutBase::build
1 call to BaseLayoutBase::build()
- BaseOneColumnLayout::build in modules/
layout_builder_base_library/ src/ Plugin/ Layout/ BaseOneColumnLayout.php - Build a render array for layout with regions.
1 method overrides BaseLayoutBase::build()
- BaseOneColumnLayout::build in modules/
layout_builder_base_library/ src/ Plugin/ Layout/ BaseOneColumnLayout.php - Build a render array for layout with regions.
File
- src/
Plugin/ Layout/ BaseLayoutBase.php, line 527
Class
- BaseLayoutBase
- Configurable layout plugin class.
Namespace
Drupal\layout_builder_base\Plugin\LayoutCode
public function build(array $regions) {
$build = parent::build($regions);
$classes = [
$this->configuration['background'],
$this->configuration['background_attachment'],
$this->configuration['background_position'],
$this->configuration['background_size'],
$this->configuration['background_overlay'],
$this->configuration['top_margin'],
$this->configuration['bottom_margin'],
$this->configuration['left_margin'],
$this->configuration['right_margin'],
$this->configuration['equal_top_bottom_margins'],
$this->configuration['equal_left_right_margins'],
$this->configuration['top_padding'],
$this->configuration['bottom_padding'],
$this->configuration['left_padding'],
$this->configuration['right_padding'],
$this->configuration['equal_top_bottom_paddings'],
$this->configuration['equal_left_right_paddings'],
$this->configuration['container'],
$this->configuration['content_container'],
$this->configuration['height'],
$this->configuration['color'],
$this->configuration['alignment'],
$this->configuration['column_gap'],
$this->configuration['row_gap'],
$this->configuration['column_breakpoint'],
$this->configuration['column_width'],
$this->configuration['align_items'],
$this->configuration['modifiers'],
$this->configuration['customizable_columns'],
];
$build_classes = array_merge($build['#attributes']['class'], $classes);
$build['#attributes']['class'] = $build_classes;
if (!empty($this->configuration['background_image'])) {
$image = File::load($this->configuration['background_image']);
if (!empty($image)) {
$uri = $image->uri->value;
$style = $this->configuration['background_image_style'];
if (!empty($style)) {
$uri = ImageStyle::load($style)
->buildUrl($image
->getFileUri());
}
$url = file_create_url($uri);
$build['#attributes']['style'] = 'background-image: url("' . $url . '")';
}
}
return $build;
}