public function UltimenuSettingsForm::submitForm in Ultimenu 8.2
Implements \Drupal\Core\Form\FormInterface::submitForm().
Overrides ConfigFormBase::submitForm
File
- src/
Form/ UltimenuSettingsForm.php, line 257
Class
- UltimenuSettingsForm
- Defines ultimenu admin settings form.
Namespace
Drupal\ultimenu\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$data = [];
// Do not litter the ultimenu.settings.yml.
$data['blocks'] = array_filter($form_state
->getValue('blocks'));
$data['regions'] = array_filter($form_state
->getValue('regions'));
$data['goodies'] = array_filter($form_state
->getValue('goodies'));
$config = $this->configFactory
->getEditable('ultimenu.settings');
if ($form_state
->hasValue('blocks')) {
$config
->set('blocks', $data['blocks']);
}
if ($form_state
->hasValue('regions')) {
$config
->set('regions', $data['regions']);
}
if ($form_state
->hasValue('goodies')) {
$config
->set('goodies', $data['goodies']);
}
foreach ([
'skins',
'fallback_text',
'ajaxmw',
] as $key) {
if ($form_state
->hasValue($key)) {
$config
->set($key, $form_state
->getValue($key));
}
}
$config
->save();
// Reset static and theme info to get the new blocks and regions fetched.
$this->ultimenuSkin
->clearCachedDefinitions();
// Invalidate the block cache to update ultimenu-based derivatives.
$this->blockManager
->clearCachedDefinitions();
$this->configFactory
->clearStaticCache();
// If anything fails, notice to clear the cache.
$this->messenger
->addMessage($this
->t('Be sure to <a href=":clear_cache">clear the cache</a> <strong>ONLY IF</strong> trouble to see the updated regions at <a href=":block_admin">block admin</a>, or when changing off-canvas.', [
':clear_cache' => Url::fromRoute('system.performance_settings')
->toString(),
':block_admin' => Url::fromRoute('block.admin_display')
->toString(),
]));
parent::submitForm($form, $form_state);
}