private function GridStackEnginePluginBase::prepare in GridStack 8.2
Prepares the settings, selector and active styles.
1 call to GridStackEnginePluginBase::prepare()
- GridStackEnginePluginBase::build in src/
GridStackEnginePluginBase.php - Alters GridStack build.
File
- src/
GridStackEnginePluginBase.php, line 239
Class
- GridStackEnginePluginBase
- Provides base class for all gridstack layout engines.
Namespace
Drupal\gridstackCode
private function prepare(array &$element, array &$settings) {
$attributes = $content_attributes = [];
$settings = array_merge($settings, $this->stylizer
->getStyle('all', $settings));
$settings['_level'] = GridStackDefault::LEVEL_ROOT;
$settings['rid'] = $settings['_context'] = GridStackDefault::ROOT;
$selector = '.gridstack--' . str_replace('_', '-', $settings['optionset']);
// Unique class per layout which can be many similar on a page.
if (isset($settings['gid']) && ($gid = $settings['gid'])) {
$selector .= '.is-gs-' . str_replace([
'_',
':',
], '-', $gid);
}
// @todo $settings['_ungrid'] = empty($settings['_ipe']) && $this->stylizer->getStyle('parallax', $settings);
if (!empty($this
->containerClasses()[0])) {
$selector .= '.' . $this
->containerClasses()[0];
}
$settings['_selector'] = $selector;
$this
->setConfiguration($settings);
// Provides attributes and background media if so configured.
// Runs before ::containerAttributes to pass the media settings.
$this->stylizer
->prepare($element, $attributes, $settings, $this
->getOptionset());
// Runs after ::media to process the media settings.
$this
->containerAttributes($attributes, $settings);
$this
->contentAttributes($content_attributes, $settings);
// Pass attributes and items to templates.
$element['#attributes'] = empty($element['#attributes']) ? $attributes : NestedArray::mergeDeep($element['#attributes'], $attributes);
$element['#content_attributes'] = empty($element['#content_attributes']) ? $content_attributes : NestedArray::mergeDeep($element['#content_attributes'], $content_attributes);
$element['#settings'] = empty($element['#settings']) ? $settings : NestedArray::mergeDeep($element['#settings'], $settings);
}