You are here

public function LockrMigrateForm::buildForm in Lockr 4.x

Same name and namespace in other branches
  1. 8.4 src/Form/LockrMigrateForm.php \Drupal\lockr\Form\LockrMigrateForm::buildForm()
  2. 8.2 src/Form/LockrMigrateForm.php \Drupal\lockr\Form\LockrMigrateForm::buildForm()
  3. 8.3 src/Form/LockrMigrateForm.php \Drupal\lockr\Form\LockrMigrateForm::buildForm()

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/LockrMigrateForm.php, line 81

Class

LockrMigrateForm
Form handler for Lockr move to production.

Namespace

Drupal\lockr\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $build_info = $form_state
    ->getBuildInfo();
  $info = $build_info['args'][0];
  $form['instructions'] = [
    '#preix' => '<p>',
    '#markup' => $this
      ->t('Click the button below to deploy this site to production. This should only be done in your production environment as it writes a new certificate to the file system.'),
    '#suffix' => '</p>',
  ];
  $form['#attached']['library'][] = 'lockr/move_to_prod';
  $form['#attached']['drupalSettings']['lockr'] = [
    'accounts_host' => 'https://accounts.lockr.io',
    'keyring_id' => $info['keyring']['id'],
  ];
  $form['client_token'] = [
    '#type' => 'hidden',
    '#required' => TRUE,
  ];
  $form['move_to_prod'] = [
    '#type' => 'button',
    '#value' => $this
      ->t('Migrate to Production'),
    '#attributes' => [
      'class' => [
        'move-to-prod',
      ],
    ],
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Submit'),
    '#attributes' => [
      'class' => [
        'move-to-prod-submit',
      ],
    ],
  ];
  return $form;
}