You are here

public function BaseLayoutBase::submitConfigurationForm in Layout Builder Base 8

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 MultiWidthLayoutBase::submitConfigurationForm

File

src/Plugin/Layout/BaseLayoutBase.php, line 472

Class

BaseLayoutBase
Configurable layout plugin class.

Namespace

Drupal\layout_builder_base\Plugin\Layout

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  parent::submitConfigurationForm($form, $form_state);
  $grid_values = $form_state
    ->getValue('grid');
  $background_values = $form_state
    ->getValue('background_detail');
  $padding_values = $form_state
    ->getValue('padding');
  $margin_values = $form_state
    ->getValue('margin');
  $container_values = $form_state
    ->getValue('container_detail');
  $style_values = $form_state
    ->getValue('styles');
  $background_file = !empty($background_values['background_image']) ? $background_values['background_image'] : 0;
  if (isset($background_file[0]) && !empty($background_file[0])) {
    $file = File::load($background_file[0]);
    $file
      ->setPermanent();
    $file
      ->save();
  }
  $image_background_style = $background_values['background_image_style'];
  $this->configuration['background_image'] = !empty($file) ? $file
    ->id() : '';
  $this->configuration['background_image_style'] = !empty($image_background_style) ? $image_background_style : '';
  $this->configuration['background'] = $background_values['background'] ?? '';
  $this->configuration['background_attachment'] = $background_values['background_attachment'] ?? '';
  $this->configuration['background_position'] = $background_values['background_position'] ?? '';
  $this->configuration['background_size'] = $background_values['background_size'] ?? '';
  $this->configuration['background_overlay'] = $background_values['background_overlay'] ?? '';
  $this->configuration['top_margin'] = $margin_values['top_margin'] ?? '';
  $this->configuration['bottom_margin'] = $margin_values['bottom_margin'] ?? '';
  $this->configuration['left_margin'] = $margin_values['left_margin'] ?? '';
  $this->configuration['right_margin'] = $margin_values['right_margin'] ?? '';
  $this->configuration['equal_top_bottom_margins'] = $margin_values['equal_top_bottom_margins'] ?? '';
  $this->configuration['equal_left_right_margins'] = $margin_values['equal_left_right_margins'] ?? '';
  $this->configuration['equal_top_bottom_paddings'] = $padding_values['equal_top_bottom_paddings'] ?? '';
  $this->configuration['equal_left_right_paddings'] = $padding_values['equal_left_right_paddings'] ?? '';
  $this->configuration['top_padding'] = $padding_values['top_padding'] ?? '';
  $this->configuration['bottom_padding'] = $padding_values['bottom_padding'] ?? '';
  $this->configuration['left_padding'] = $padding_values['left_padding'] ?? '';
  $this->configuration['right_padding'] = $padding_values['right_padding'] ?? '';
  $this->configuration['container'] = $container_values['container'] ?? '';
  $this->configuration['content_container'] = $container_values['content_container'] ?? '';
  $this->configuration['height'] = $container_values['height'] ?? '';
  $this->configuration['color'] = $style_values['color'] ?? '';
  $this->configuration['alignment'] = $style_values['alignment'] ?? '';
  $this->configuration['column_gap'] = $grid_values['column_gap'] ?? '';
  $this->configuration['row_gap'] = $grid_values['row_gap'] ?? '';
  $this->configuration['column_width'] = $grid_values['column_width'] ?? '';
  $this->configuration['column_breakpoint'] = $grid_values['column_breakpoint'] ?? '';
  $this->configuration['align_items'] = $grid_values['align_items'] ?? '';
  $this->configuration['modifiers'] = $style_values['modifiers'] ?? '';
  $this->configuration['customizable_columns'] = $grid_values['customizable_columns'] ?? '';
}