public function Builder::getVariantEditor in GridStack 8.2
Returns the AJAX CRUD container for layout variants.
File
- src/
Plugin/ gridstack/ stylizer/ Builder.php, line 346
Class
- Builder
- Provides Layout Builder integration for editor previews.
Namespace
Drupal\gridstack\Plugin\gridstack\stylizerCode
public function getVariantEditor(array $settings, $optionset, $reload = FALSE) {
$exists = $this->manager
->getModuleHandler()
->moduleExists('gridstack_ui');
$access = $this->currentUser
->hasPermission('modify gridstack variant');
if (!$exists || !$access) {
return [];
}
// Bail out if no unique ID per layout, to support multiple similar layouts.
if (empty($settings['gid'])) {
return [];
}
$links = $this
->getVariantLinks($settings, $optionset, $reload);
$pos = $this
->config('editor_pos') == 'bottom' ? 'bottom' : 'top';
return $links ? [
'#type' => 'container',
'#attributes' => [
'class' => [
'gridstack-editor',
'gridstack-editor--' . $pos,
],
],
'#attached' => [
'library' => [
'core/drupal.ajax',
'gridstack/admin',
],
],
'form' => [
'#type' => 'container',
'#attributes' => [
'id' => GridStackDefault::variantWrapperId($settings['gid']),
'class' => [
'gridstack-editor__form',
'clearfix',
],
'data-gs-gid' => GridStackDefault::gid($settings['gid']),
],
'add' => $links['add'],
'edit' => $links['edit'],
'select' => $links['select'],
],
] : [];
}