You are here

public function DsLayout::submitConfigurationForm in Display Suite 8.4

Same name and namespace in other branches
  1. 8.2 src/Plugin/DsLayout.php \Drupal\ds\Plugin\DsLayout::submitConfigurationForm()
  2. 8.3 src/Plugin/DsLayout.php \Drupal\ds\Plugin\DsLayout::submitConfigurationForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides LayoutDefault::submitConfigurationForm

File

src/Plugin/DsLayout.php, line 202

Class

DsLayout
Layout class for all Display Suite layouts.

Namespace

Drupal\ds\Plugin

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  $this->configuration['wrappers'] = $form_state
    ->getValue('region_wrapper');
  foreach ([
    'outer_wrapper',
    'attributes',
    'link_attribute',
    'link_custom',
  ] as $name) {
    $this->configuration[$name] = $this->configuration['wrappers'][$name];
    unset($this->configuration['wrappers'][$name]);
  }

  // Apply Xss::filter to attributes.
  $this->configuration['attributes'] = Xss::filter($this->configuration['attributes']);

  // In case classes is missing entirely, use the defaults.
  $defaults = $this
    ->defaultConfiguration();
  $this->configuration['classes'] = $form_state
    ->getValue('ds_classes', $defaults['classes']);

  // Do not save empty classes.
  foreach ($this->configuration['classes'] as $region_name => &$classes) {
    foreach ($classes as $class) {
      if (empty($class)) {
        unset($classes[$class]);
      }
    }
  }
}