You are here

public function BlazySettingsForm::submitForm in Blazy 8

Same name and namespace in other branches
  1. 8.2 blazy_ui/src/Form/BlazySettingsForm.php \Drupal\blazy_ui\Form\BlazySettingsForm::submitForm()
  2. 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 112

Class

BlazySettingsForm
Defines blazy admin settings form.

Namespace

Drupal\blazy_ui\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this->configFactory
    ->getEditable('blazy.settings')
    ->set('admin_css', $form_state
    ->getValue('admin_css'))
    ->set('responsive_image', $form_state
    ->getValue('responsive_image'))
    ->set('one_pixel', $form_state
    ->getValue('one_pixel'))
    ->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',
  ]))
    ->save();

  // Invalidate the library discovery cache to update the responsive image.
  \Drupal::service('library.discovery')
    ->clearCachedDefinitions();
  $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);
}