You are here

function template_preprocess_gridstack in GridStack 8.2

Same name and namespace in other branches
  1. 8 templates/gridstack.theme.inc \template_preprocess_gridstack()

Prepares variables for gridstack.html.twig templates.

1 call to template_preprocess_gridstack()
template_preprocess_gridstack_ui_admin in modules/gridstack_ui/templates/gridstack_ui.theme.inc
Prepares variables for gridstack-ui-admin.html.twig templates.
1 string reference to 'template_preprocess_gridstack'
template_preprocess_gridstack_ui_admin in modules/gridstack_ui/templates/gridstack_ui.theme.inc
Prepares variables for gridstack-ui-admin.html.twig templates.

File

templates/gridstack.theme.inc, line 14
Hooks and preprocess functions for the GridStack module.

Code

function template_preprocess_gridstack(&$variables) {
  $element = $variables['element'];
  foreach (GridStackDefault::themeProperties() as $key) {
    $variables[$key] = isset($element['#' . $key]) ? $element['#' . $key] : [];
  }
  $settings =& $variables['settings'];
  $settings += GridStackDefault::htmlSettings();
  $attributes =& $variables['attributes'];
  $custom_classes = empty($attributes['class']) ? [] : $attributes['class'];
  $attributes['class'] = array_merge([
    'gridstack',
  ], $custom_classes);
  $variables['wrapper'] = empty($settings['wrapper']) ? 'div' : $settings['wrapper'];
  $variables['wrapper_attributes'] = new Attribute($variables['wrapper_attributes']);
  $variables['content_attributes'] = empty($variables['content_attributes']) ? [] : new Attribute($variables['content_attributes']);
}