function SwitchUserPageForm::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/SwitchUserPageForm.php, line 47

Class

SwitchUserPageForm
Define an accessible form to switch the user.

Namespace

Drupal\devel\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) : array {
  if ($accounts = $this->switchUserListHelper
    ->getUsers()) {
    $form['devel_links'] = $this->switchUserListHelper
      ->buildUserList($accounts);
    $form['devel_form'] = $this->formBuilder
      ->getForm(SwitchUserForm::class);
  }
  else {
    $this->messenger
      ->addStatus('There are no user accounts present!');
  }
  return $form;
}