You are here

public function PanelizerAddWizard::submitForm in Panelizer 8.4

Same name and namespace in other branches
  1. 8.5 src/Wizard/PanelizerAddWizard.php \Drupal\panelizer\Wizard\PanelizerAddWizard::submitForm()
  2. 8.3 src/Wizard/PanelizerAddWizard.php \Drupal\panelizer\Wizard\PanelizerAddWizard::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 FormWizardBase::submitForm

File

src/Wizard/PanelizerAddWizard.php, line 38

Class

PanelizerAddWizard

Namespace

Drupal\panelizer\Wizard

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $operations = array_map('strval', [
    $this
      ->getNextOp(),
    $this
      ->t('Update'),
    $this
      ->t('Update and save'),
    $this
      ->t('Save'),
  ]);
  if (in_array($form_state
    ->getValue('op'), $operations)) {
    $cached_values = $form_state
      ->getTemporaryValue('wizard');
    if ($form_state
      ->hasValue('label')) {
      $config = $cached_values['plugin']
        ->getConfiguration();
      $config['label'] = $form_state
        ->getValue('label');
      $cached_values['plugin']
        ->setConfiguration($config);
    }
    if ($form_state
      ->hasValue('id')) {
      $cached_values['id'] = $form_state
        ->getValue('id');

      /** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $plugin */
      $plugin = $cached_values['plugin'];
      $plugin
        ->setStorage($plugin
        ->getStorageType(), $cached_values['id']);
    }
  }
  parent::submitForm($form, $form_state);
}