private function Builder::lb in GridStack 8.2
Provides Layout Builder attributes.
1 call to Builder::lb()
- Builder::adminAttributes in src/
Plugin/ gridstack/ stylizer/ Builder.php - Provides Layout Builder attributes if available.
File
- src/
Plugin/ gridstack/ stylizer/ Builder.php, line 128
Class
- Builder
- Provides Layout Builder integration for editor previews.
Namespace
Drupal\gridstack\Plugin\gridstack\stylizerCode
private function lb(array &$box, array &$content_attributes, array $settings, array $region = []) {
$rid = isset($settings['rid']) ? $settings['rid'] : -1;
$content_attributes = NestedArray::mergeDeep($content_attributes, $region['#attributes']);
// Provides add block and contextual links.
if (isset($region['layout_builder_add_block'])) {
$link = $region['layout_builder_add_block'];
$link['#attributes']['class'][] = 'gridstack__action';
$link['#attributes']['data-gs-region'] = $rid;
$link['#weight'] = 100;
if (isset($link['link'], $link['link']['#url'])) {
$label = 'data-layout-content-preview-placeholder-label';
foreach (Element::children($box) as $uuid) {
$params = $link['link']['#url']
->getRouteParameters() + [
'uuid' => $uuid,
];
$fallback = isset($box[$uuid]['#attributes'][$label]) ? $box[$uuid]['#attributes'][$label] : '';
$box[$uuid]['#attributes']['class'][] = 'js-layout-builder-block layout-builder-block';
$box[$uuid]['#attributes']['data-layout-block-uuid'] = $uuid;
$box[$uuid]['#attributes']['data-layout-builder-highlight-id'] = $uuid;
if (!empty($settings['_lbux'])) {
assert(isset($box[$uuid]['content']));
$box[$uuid]['content'] = [
'actions' => $this
->lbux($params, $fallback),
'content' => $box[$uuid]['content'],
];
}
else {
$box[$uuid]['#contextual_links'] = $this
->contextualLinks($params);
}
}
}
if (isset($region['region_label'])) {
$box['region_label'] = $region['region_label'];
}
$box['add_block'] = $link;
}
}