You are here

public function BootstrapLayout::submitConfigurationForm in Bootstrap Layout Builder 1.x

Same name and namespace in other branches
  1. 2.x src/Plugin/Layout/BootstrapLayout.php \Drupal\bootstrap_layout_builder\Plugin\Layout\BootstrapLayout::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/Layout/BootstrapLayout.php, line 537

Class

BootstrapLayout
A layout from our bootstrap layout builder.

Namespace

Drupal\bootstrap_layout_builder\Plugin\Layout

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  parent::submitConfigurationForm($form, $form_state);

  // The tabs structure.
  $layout_tab = [
    'ui',
    'tab_content',
    'layout',
  ];
  $style_tab = [
    'ui',
    'tab_content',
    'appearance',
  ];
  $settings_tab = [
    'ui',
    'tab_content',
    'settings',
  ];

  // Save sction label.
  $this->configuration['label'] = $form_state
    ->getValue(array_merge($settings_tab, [
    'label',
  ]));

  // Container type.
  $this->configuration['container'] = '';
  if ($form_state
    ->getValue(array_merge($layout_tab, [
    'has_container',
  ]))) {
    $this->configuration['container'] = $form_state
      ->getValue(array_merge($layout_tab, [
      'container_type',
    ]));

    // Container wrapper.
    $this->configuration['container_wrapper_bg_color_class'] = $form_state
      ->getValue(array_merge($style_tab, [
      'container_wrapper_bg_color_class',
    ]));
    $this->configuration['container_wrapper_bg_media'] = $form_state
      ->getValue(array_merge($style_tab, [
      'container_wrapper_bg_media',
    ]));

    // Container classes from advanced mode.
    if (!$this
      ->sectionSettingsIsHidden()) {
      $this->configuration['container_wrapper_classes'] = $form_state
        ->getValue(array_merge($settings_tab, [
        'container',
        'container_wrapper_classes',
      ]));
    }
  }

  // Gutter Classes
  $this->configuration['remove_gutters'] = $form_state
    ->getValue(array_merge($layout_tab, [
    'remove_gutters',
  ]));

  // Row classes from advanced mode.
  if (!$this
    ->sectionSettingsIsHidden()) {
    $this->configuration['section_classes'] = $form_state
      ->getValue(array_merge($settings_tab, [
      'row',
      'section_classes',
    ]));
  }
  $breakpoints = $form_state
    ->getValue(array_merge($layout_tab, [
    'breakpoints',
  ]));

  // Save breakpoints configuration.
  $this
    ->saveBreakpoints($breakpoints);
  foreach ($this
    ->getPluginDefinition()
    ->getRegionNames() as $key => $region_name) {

    // Save layout region classes.
    $this->configuration['layout_regions_classes'][$region_name] = $this
      ->getRegionClasses($key, $breakpoints);

    // Cols classes from advanced mode.
    if (!$this
      ->sectionSettingsIsHidden()) {
      $this->configuration['regions_classes'][$region_name] = $form_state
        ->getValue(array_merge($settings_tab, [
        'regions',
        $region_name . '_classes',
      ]));
    }
  }
}