function SettingsForm::submitForm
Same name in this branch
- 11.x core/modules/media_library/src/Form/SettingsForm.php \Drupal\media_library\Form\SettingsForm::submitForm()
Same name in other branches
- 9 core/modules/media_library/src/Form/SettingsForm.php \Drupal\media_library\Form\SettingsForm::submitForm()
- 9 core/modules/aggregator/src/Form/SettingsForm.php \Drupal\aggregator\Form\SettingsForm::submitForm()
- 8.9.x core/modules/media_library/src/Form/SettingsForm.php \Drupal\media_library\Form\SettingsForm::submitForm()
- 8.9.x core/modules/aggregator/src/Form/SettingsForm.php \Drupal\aggregator\Form\SettingsForm::submitForm()
- 10 core/modules/media_library/src/Form/SettingsForm.php \Drupal\media_library\Form\SettingsForm::submitForm()
- 10 core/modules/navigation/src/Form/SettingsForm.php \Drupal\navigation\Form\SettingsForm::submitForm()
Overrides ConfigFormBase::submitForm
File
-
core/
modules/ navigation/ src/ Form/ SettingsForm.php, line 223
Class
- SettingsForm
- Configure Navigation settings for this site.
Namespace
Drupal\navigation\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) : void {
// If the user uploaded a new logo, save it to a permanent location
// and use it in place of the default navigation-provided file.
$default_scheme = $this->config('system.file')
->get('default_scheme');
$values = $form_state->getValues();
try {
if (!empty($values['logo_upload'])) {
$filename = $this->fileSystem
->copy($values['logo_upload']->getFileUri(), $default_scheme . '://');
$values['logo_path'] = $filename;
if ($values['logo_dimensions']['resize']) {
$config = $this->config('navigation.settings');
$this->messenger()
->addStatus($this->t('The image was resized to fit within the navigation logo expected dimensions of %widthx%height pixels. The new dimensions of the resized image are %new_widthx%new_height pixels.', [
'%width' => $config->get('logo.max.width'),
'%height' => $config->get('logo.max.height'),
'%new_width' => $values['logo_dimensions']['width'],
'%new_height' => $values['logo_dimensions']['height'],
]));
}
}
} catch (FileException) {
$this->messenger()
->addError($this->t('The file %file could not be copied to the permanent destination. Contact the site administrator if the problem persists.', [
'%file' => $values['logo_upload']->getFilename(),
]));
return;
}
// If the user entered a path relative to the system files directory for
// the logo, store a public:// URI so the theme system can handle it.
if (!empty($values['logo_path'])) {
$form_state->setValue('logo_path', $this->validateLogoPath($values['logo_path']));
}
parent::submitForm($form, $form_state);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.