public function WebformAdminConfigAdvancedForm::submitForm in Webform 8.5
Same name and namespace in other branches
- 6.x src/Form/AdminConfig/WebformAdminConfigAdvancedForm.php \Drupal\webform\Form\AdminConfig\WebformAdminConfigAdvancedForm::submitForm()
Form submission handler.
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 WebformAdminConfigBaseForm::submitForm
File
- src/
Form/ AdminConfig/ WebformAdminConfigAdvancedForm.php, line 341
Class
- WebformAdminConfigAdvancedForm
- Configure webform admin advanced settings.
Namespace
Drupal\webform\Form\AdminConfigCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$op = (string) $form_state
->getValue('op');
if ($op === (string) $this
->t('Repair configuration')) {
// Copied from:
// @see \Drupal\webform\Commands\WebformCliService::drush_webform_repair
module_load_include('install', 'webform');
$this
->messenger()
->addMessage($this
->t('Repairing webform submission storage schema…'));
_webform_update_webform_submission_storage_schema();
$this
->messenger()
->addMessage($this
->t('Repairing admin configuration…'));
_webform_update_admin_settings(TRUE);
$this
->messenger()
->addMessage($this
->t('Repairing webform settings…'));
_webform_update_webform_settings();
$this
->messenger()
->addMessage($this
->t('Repairing webform handlers…'));
_webform_update_webform_handler_settings();
$this
->messenger()
->addMessage($this
->t('Repairing webform field storage definitions…'));
_webform_update_field_storage_definitions();
$this
->messenger()
->addMessage($this
->t('Repairing webform submission storage schema…'));
_webform_update_webform_submission_storage_schema();
if ($this->moduleHandler
->moduleExists('webform_entity_print')) {
$this
->messenger()
->addMessage($this
->t('Repairing webform entity print settings…'));
module_load_include('install', 'webform_entity_print');
webform_entity_print_install();
}
$this
->messenger()
->addMessage($this
->t('Removing (unneeded) webform submission translation settings…'));
_webform_update_webform_submission_translation();
drupal_flush_all_caches();
$this
->messenger()
->addStatus($this
->t('Webform configuration has been repaired.'));
}
else {
// Update config and submit form.
$config = $this
->config('webform.settings');
$config
->set('ui', $form_state
->getValue('ui'));
$config
->set('requirements', $form_state
->getValue('requirements'));
$config
->set('test', $form_state
->getValue('test'));
$config
->set('batch', $form_state
->getValue('batch'));
// Track if help is disabled.
// @todo Figure out how to clear cached help block.
$is_help_disabled = $config
->getOriginal('ui.help_disabled') !== $config
->get('ui.help_disabled');
$is_toolbar_item = $config
->getOriginal('ui.toolbar_item') !== $config
->get('ui.toolbar_item');
parent::submitForm($form, $form_state);
// Clear cached data.
if ($is_help_disabled || $is_toolbar_item) {
// Flush cache when help is being enabled.
// @see webform_help()
drupal_flush_all_caches();
}
else {
// Clear render cache so that local tasks can be updated to hide/show
// the 'Contribute' tab.
// @see webform_local_tasks_alter()
$this->renderCache
->deleteAll();
$this->routerBuilder
->rebuild();
}
// Redirect to the update advanced admin configuration form.
if ($is_toolbar_item) {
$path = $config
->get('ui.toolbar_item') ? '/admin/webform/config/advanced' : '/admin/structure/webform/config/advanced';
$form_state
->setRedirectUrl(Url::fromUserInput($path));
}
}
}