protected function LayoutParagraphsBuilder::insertComponentButton in Layout Paragraphs 2.0.x
Returns the render array for a insert component button.
Parameters
array[] $route_params: The route parameters for the link.
array[] $query_params: The query paramaters 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::insertComponentButton()
- 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 441
Class
- LayoutParagraphsBuilder
- Defines a render element for building the Layout Builder UI.
Namespace
Drupal\layout_paragraphs\ElementCode
protected function insertComponentButton(array $route_params = [], array $query_params = [], int $weight = 0, array $classes = []) {
return [
'#type' => 'link',
'#title' => Markup::create('<span class="visually-hidden">' . $this
->t('Choose component') . '</span>'),
'#weight' => $weight,
'#attributes' => [
'class' => array_merge([
'lpb-btn--add',
'use-ajax',
], $classes),
'data-dialog-type' => 'dialog',
'data-dialog-options' => Json::encode([
'target' => $this
->dialogId($this->layoutParagraphsLayout),
'modal' => TRUE,
]),
],
'#url' => Url::fromRoute('layout_paragraphs.builder.choose_component', $route_params, [
'query' => $query_params,
]),
];
}