You are here

public function PanelizerEditWizard::submitForm in Panelizer 8.3

Same name and namespace in other branches
  1. 8.5 src/Wizard/PanelizerEditWizard.php \Drupal\panelizer\Wizard\PanelizerEditWizard::submitForm()
  2. 8.4 src/Wizard/PanelizerEditWizard.php \Drupal\panelizer\Wizard\PanelizerEditWizard::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/PanelizerEditWizard.php, line 171

Class

PanelizerEditWizard

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');
    }
    if (is_null($this->machine_name) && !empty($cached_values['id'])) {
      $this->machine_name = $cached_values['id'];
    }
    $this
      ->getTempstore()
      ->set($this
      ->getMachineName(), $cached_values);
    if (!$form_state
      ->get('ajax')) {
      $form_state
        ->setRedirect($this
        ->getRouteName(), $this
        ->getNextParameters($cached_values));
    }
  }
}