public function VarnishPurgerFormBase::submitFormSuccess in Varnish purger 8.2
Same name and namespace in other branches
- 8 src/Form/VarnishPurgerFormBase.php \Drupal\varnish_purger\Form\VarnishPurgerFormBase::submitFormSuccess()
Form submission handler only called when there are no validation errors.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides PluginConfigFormBase::submitFormSuccess
File
- src/
Form/ VarnishPurgerFormBase.php, line 459
Class
- VarnishPurgerFormBase
- Abstract form base for Varnish based configurable purgers.
Namespace
Drupal\varnish_purger\FormCode
public function submitFormSuccess(array &$form, FormStateInterface $form_state) {
$settings = VarnishPurgerSettings::load($this
->getId($form_state));
// Rewrite 'headers' so that it contains the exact right format for CMI.
if (!is_null($submitted_headers = $form_state
->getValue('headers'))) {
$headers = [];
foreach ($submitted_headers as $header) {
if (strlen($header['field'] && strlen($header['value']))) {
$headers[] = $header;
}
}
$form_state
->setValue('headers', $headers);
}
// Iterate the config object and overwrite values found in the form state.
foreach ($settings as $key => $default_value) {
if (!is_null($value = $form_state
->getValue($key))) {
$settings->{$key} = $value;
}
}
$settings
->save();
}