protected function Form::massageAllClasses in GridStack 8.2
Returns merged $[wrapper|row]_classes and $selected_classes.
We do this since we don't store massive class options, instead interpolated into the existing string [wrapper|row]_classes option during form validation to avoid similar logic at front-end.
2 calls to Form::massageAllClasses()
- Form::massageClasses in src/
Plugin/ gridstack/ stylizer/ Form.php - Returns merged classes for .row or .box__content.
- Form::massageRowClasses in src/
Plugin/ gridstack/ stylizer/ Form.php - Returns merged classes for .row only.
File
- src/
Plugin/ gridstack/ stylizer/ Form.php, line 212
Class
- Form
- Provides the form elements.
Namespace
Drupal\gridstack\Plugin\gridstack\stylizerCode
protected function massageAllClasses(FormStateInterface $form_state, $name, $wrapper_class = '', array $selected_classes = [], array $classes = []) {
$wrapper_classes = $wrapper_class ? array_map('trim', explode(" ", $wrapper_class)) : [];
$wrapper_classes = $wrapper_class ? array_combine($wrapper_classes, $wrapper_classes) : [];
$selected_classes = array_filter($selected_classes);
if ($selected_classes) {
$selected_classes = array_values($selected_classes);
$selected_classes = array_combine($selected_classes, $selected_classes);
}
// If $selected_classes are left empty, remove it from $wrapper_classes.
// Ensures to not remove custom defined classes.
if ($wrapper_classes) {
foreach ($wrapper_classes as $key => $value) {
if (isset($classes[$key]) && !isset($selected_classes[$key])) {
unset($wrapper_classes[$key]);
}
}
}
$wrapper_classes = $selected_classes ? array_merge($wrapper_classes, $selected_classes) : $wrapper_classes;
$wrapper_classes = array_unique(array_values($wrapper_classes));
$merged = $wrapper_classes ? implode(" ", $wrapper_classes) : '';
$form_state
->setValue($name, $merged);
}