You are here

public function LayoutPluginSelector::submitForm in Panels 8.3

Same name and namespace in other branches
  1. 8.4 src/Form/LayoutPluginSelector.php \Drupal\panels\Form\LayoutPluginSelector::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/LayoutPluginSelector.php, line 96

Class

LayoutPluginSelector
Provides a form for selecting a layout plugin.

Namespace

Drupal\panels\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $cached_values = $form_state
    ->getTemporaryValue('wizard');

  /* @var $variant_plugin \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant */
  $variant_plugin = $cached_values['plugin'];

  // If we're changing the layout, the variant plugin must remain out of date
  // until the layout is fully configured and regions are remapped.
  if ($form_state
    ->getValue('op') == $form['update_layout']['#value']) {
    $cached_values['layout_change'] = [
      'old_layout' => $variant_plugin
        ->getConfiguration()['layout'],
      'new_layout' => $form_state
        ->getValue('layout'),
    ];

    /** @var \Drupal\ctools\Wizard\EntityFormWizardInterface $wizard */
    $wizard = $form_state
      ->getFormObject();
    $next_op = $wizard
      ->getNextOp();
    $form_state
      ->setValue('op', $next_op);
  }
  $variant_plugin
    ->setLayout($form_state
    ->getValue('layout'), $form_state
    ->getValue('layout_settings') ?: []);
  $cached_values['plugin'] = $variant_plugin;
  $form_state
    ->setTemporaryValue('wizard', $cached_values);
}