You are here

public function EnvironmentSwitchConfirm::submitForm in Environment 8

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/EnvironmentSwitchConfirm.php, line 40
Contains \Drupal\environment\Form\EnvironmentSwitchConfirm.

Class

EnvironmentSwitchConfirm

Namespace

Drupal\environment\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if (isset($form['environment'])) {
    foreach ($form['environment'] as $workflow => $environment) {
      if ($form_state
        ->getValue([
        'environment',
        $workflow,
      ]) != $form['environment'][$workflow]) {
        environment_switch($form_state
          ->getValue([
          'environment',
          $workflow,
        ]), $workflow);
      }
    }
  }
  $form_state
    ->set([
    'redirect',
  ], 'admin/settings/environment');
}