public static function PatternDisplayFormTrait::processFormStateValues in UI Patterns 8
Normalize settings coming from a form submission.
Parameters
array $settings: Pattern display form values array.
2 calls to PatternDisplayFormTrait::processFormStateValues()
- Pattern::submitOptionsForm in modules/
ui_patterns_views/ src/ Plugin/ views/ row/ Pattern.php - Perform any necessary changes to the form values prior to storage. There is no need for this function to actually store the data.
- ui_patterns_ds_field_overview_submit in modules/
ui_patterns_ds/ ui_patterns_ds.module - Form submit callback to fix the field_group configuration.
File
- src/
Form/ PatternDisplayFormTrait.php, line 156
Class
- PatternDisplayFormTrait
- Trait PatternDisplayFormTrait.
Namespace
Drupal\ui_patterns\FormCode
public static function processFormStateValues(array &$settings) {
if (isset($settings['variants']) && isset($settings['variants'][$settings['pattern']])) {
$settings['pattern_variant'] = $settings['variants'][$settings['pattern']];
unset($settings['variants']);
}
// Normalize only when necessary.
if (isset($settings['pattern_mapping'][$settings['pattern']]['settings'])) {
$settings['pattern_mapping'] = $settings['pattern_mapping'][$settings['pattern']]['settings'];
// Process fields and filter out the hidden ones.
foreach ($settings['pattern_mapping'] as $key => $setting) {
if ($setting['destination'] == '_hidden') {
unset($settings['pattern_mapping'][$key]);
}
else {
list($plugin, $source) = explode(PatternSourceBase::DERIVATIVE_SEPARATOR, $key, 2);
$settings['pattern_mapping'][$key]['plugin'] = $plugin;
$settings['pattern_mapping'][$key]['source'] = $source;
}
}
// Normalize weights.
$weight = 0;
uasort($settings['pattern_mapping'], [
SortArray::class,
'sortByWeightElement',
]);
foreach ($settings['pattern_mapping'] as $key => $setting) {
$settings['pattern_mapping'][$key]['weight'] = $weight++;
}
}
}