gridstack_ui.theme.inc in GridStack 8.2
Hooks and preprocess functions for the GridStack UI module.
File
modules/gridstack_ui/templates/gridstack_ui.theme.incView source
<?php
/**
* @file
* Hooks and preprocess functions for the GridStack UI module.
*/
use Drupal\Core\Template\Attribute;
/**
* Prepares variables for gridstack-ui-admin.html.twig templates.
*/
function template_preprocess_gridstack_ui_admin(&$variables) {
if (!function_exists('template_preprocess_gridstack')) {
module_load_include('inc', 'gridstack', 'templates/gridstack.theme');
}
template_preprocess_gridstack($variables);
$element = $variables['element'];
foreach ([
'content',
'preview',
'wrapper',
] as $key) {
$variables[$key . '_attributes'] = isset($element["#{$key}" . '_attributes']) ? $element["#{$key}" . '_attributes'] : [];
}
$settings =& $variables['settings'];
$content_attributes =& $variables['content_attributes'];
$preview_attributes =& $variables['preview_attributes'];
$wrapper_attributes =& $variables['wrapper_attributes'];
$settings['id'] = 'gridstack-' . $settings['breakpoint'];
$content_attributes['id'] = $settings['id'];
$variables['wrapper_attributes']['id'] = 'gridstack-wrapper-' . $settings['breakpoint'];
$variables['wrapper_attributes']['data-breakpoint'] = $settings['breakpoint'];
$variables['content_attributes'] = new Attribute($content_attributes);
$variables['preview_attributes'] = new Attribute($preview_attributes);
$variables['wrapper_attributes'] = new Attribute($wrapper_attributes);
$variables['main_button_texts'] = [];
$settings['is_main_preview'] = FALSE;
if ($settings['breakpoint'] == $settings['icon_breakpoint']) {
$settings['is_main_preview'] = TRUE;
$variables['main_button_texts'] = [
'save' => t('Update icon'),
'add' => t('Add grid'),
];
}
}
Functions
Name | Description |
---|---|
template_preprocess_gridstack_ui_admin | Prepares variables for gridstack-ui-admin.html.twig templates. |