public function BlazySettingsForm::submitForm in Blazy 8.2
Same name and namespace in other branches
- 8 blazy_ui/src/Form/BlazySettingsForm.php \Drupal\blazy_ui\Form\BlazySettingsForm::submitForm()
- 7 modules/blazy_ui/src/Form/BlazySettingsForm.php \Drupal\blazy_ui\Form\BlazySettingsForm::submitForm()
Implements \Drupal\Core\Form\FormInterface::submitForm().
Overrides ConfigFormBase::submitForm
File
- blazy_ui/
src/ Form/ BlazySettingsForm.php, line 238
Class
- BlazySettingsForm
- Defines blazy admin settings form.
Namespace
Drupal\blazy_ui\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this->configFactory
->getEditable('blazy.settings');
$config
->set('admin_css', $form_state
->getValue('admin_css'))
->set('decode', $form_state
->getValue('decode'))
->set('fx', $form_state
->getValue('fx'))
->set('noscript', $form_state
->getValue('noscript'))
->set('responsive_image', $form_state
->getValue('responsive_image'))
->set('one_pixel', $form_state
->getValue('one_pixel'))
->set('placeholder', $form_state
->getValue('placeholder'))
->set('unstyled_extensions', $form_state
->getValue('unstyled_extensions'))
->set('blazy.loadInvisible', $form_state
->getValue([
'blazy',
'loadInvisible',
]))
->set('blazy.offset', $form_state
->getValue([
'blazy',
'offset',
]))
->set('blazy.saveViewportOffsetDelay', $form_state
->getValue([
'blazy',
'saveViewportOffsetDelay',
]))
->set('blazy.validateDelay', $form_state
->getValue([
'blazy',
'validateDelay',
]))
->set('blazy.container', $form_state
->getValue([
'blazy',
'container',
]))
->set('io.enabled', $form_state
->getValue([
'io',
'enabled',
]))
->set('io.unblazy', $form_state
->getValue([
'io',
'unblazy',
]))
->set('io.rootMargin', $form_state
->getValue([
'io',
'rootMargin',
]))
->set('io.threshold', $form_state
->getValue([
'io',
'threshold',
]))
->set('io.disconnect', $form_state
->getValue([
'io',
'disconnect',
]));
if ($form_state
->hasValue('extras')) {
foreach ($form_state
->getValue('extras') as $key => $value) {
$config
->set('extras.' . $key, $value);
}
}
$config
->save();
// Invalidate the library discovery cache to update the responsive image.
$this->libraryDiscovery
->clearCachedDefinitions();
$this->configFactory
->clearStaticCache();
$this
->messenger()
->addMessage($this
->t('Be sure to <a href=":clear_cache">clear the cache</a> if trouble to see the updated settings.', [
':clear_cache' => Url::fromRoute('system.performance_settings')
->toString(),
]));
parent::submitForm($form, $form_state);
}