protected function LayoutParagraphsBuilder::insertSectionButton in Layout Paragraphs 2.0.x
Returns the render array for a create section button.
Parameters
array[] $route_params: The route parameters for the link.
array[] $query_params: The query parameters for the link.
int $weight: The weight of the button element.
array[] $classes: A list of classes to append to the container.
Return value
array The render array.
2 calls to LayoutParagraphsBuilder::insertSectionButton()
- LayoutParagraphsBuilder::buildComponent in src/
Element/ LayoutParagraphsBuilder.php - Returns the build array for a single layout component.
- LayoutParagraphsBuilder::preRender in src/
Element/ LayoutParagraphsBuilder.php - Pre-render callback: Renders the UI.
File
- src/
Element/ LayoutParagraphsBuilder.php, line 473
Class
- LayoutParagraphsBuilder
- Defines a render element for building the Layout Builder UI.
Namespace
Drupal\layout_paragraphs\ElementCode
protected function insertSectionButton(array $route_params = [], array $query_params = [], int $weight = 0, array $classes = []) {
return [
'#type' => 'link',
'#title' => Markup::create($this
->t('Add section')),
'#attributes' => [
'class' => array_merge([
'lpb-btn',
'use-ajax',
], $classes),
'data-dialog-type' => 'dialog',
'data-dialog-options' => Json::encode($this
->dialogSettings($this->layoutParagraphsLayout)),
],
'#url' => Url::fromRoute('layout_paragraphs.builder.choose_component', $route_params, [
'query' => $query_params,
]),
];
}