You are here

public function BlazyFilter::submitForm in Blazy 7

File

src/Plugin/Filter/BlazyFilter.php, line 428

Class

BlazyFilter
Provides a filter to lazyload image, or iframe elements.

Namespace

Drupal\blazy\Plugin\Filter

Code

public function submitForm($form, &$form_state) {
  $defaults = BlazyDefault::formSettings()['filters'];
  if (isset($form_state['values']['filters']['blazy_filter'])) {
    $blazy = $form_state['values']['filters']['blazy_filter'];
    if ($blazy['status'] == 1) {
      $format = $form_state['values']['format'];
      $settings =& $blazy['settings'];
      $components['filters'] = $this->manager
        ->config('filters', []);
      foreach ($defaults as $key => $value) {
        if (isset($settings[$key])) {
          $type = gettype($value);
          settype($settings[$key], $type);
          $components['filters'][$format][$key] = $settings[$key];
        }
      }

      // Merge individual flat variables into a single blazy.settings.
      variable_set('blazy.settings', array_merge((array) $this->manager
        ->config(), $components));
    }
  }
}