You are here

public function EnvironmentSwitchConfirm::buildForm in Environment 8

Form constructor.

Parameters

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

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

Return value

array The form structure.

Overrides FormInterface::buildForm

File

src/Form/EnvironmentSwitchConfirm.php, line 23
Contains \Drupal\environment\Form\EnvironmentSwitchConfirm.

Class

EnvironmentSwitchConfirm

Namespace

Drupal\environment\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  if (empty($environment)) {
    drupal_set_message(t('Invalid environment "%environment". You cannot switch to an undefined environment.', [
      '%environment' => $environment,
    ]), 'warning');
    drupal_goto('admin/settings/environment');
  }
  return confirm_form([
    'environment' => [
      '#type' => 'hidden',
      '#value' => $environment,
    ],
  ], t('Are you sure you want to switch the current environment?'), 'admin/settings/environment', t('This action switches the current environment to "%env". This kind of change is as risky as updating your site. This action cannot be undone.', [
    '%env' => $environment,
  ]), t('Switch environment'), t('Cancel'));
}