public function ImceSettingsForm::submitForm in IMCE 8
Same name and namespace in other branches
- 8.2 src/Form/ImceSettingsForm.php \Drupal\imce\Form\ImceSettingsForm::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 ConfigFormBase::submitForm
File
- src/
Form/ ImceSettingsForm.php, line 101
Class
- ImceSettingsForm
- Imce settings form.
Namespace
Drupal\imce\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('imce.settings');
// Absolute URLs.
$config
->set('abs_urls', $form_state
->getValue('abs_urls'));
// Admin theme.
$config
->set('admin_theme', $form_state
->getValue('admin_theme'));
$roles_profiles = $form_state
->getValue('roles_profiles');
// Filter empty values.
foreach ($roles_profiles as $rid => &$profiles) {
if (!($profiles = array_filter($profiles))) {
unset($roles_profiles[$rid]);
}
}
$config
->set('roles_profiles', $roles_profiles);
$config
->save();
// Warn about anonymous access.
if (!empty($roles_profiles[RoleInterface::ANONYMOUS_ID])) {
$this
->messenger()
->addMessage($this
->t('You have enabled anonymous access to the file manager. Please make sure this is not a misconfiguration.'), 'warning');
}
parent::submitForm($form, $form_state);
}