You are here

public function ConfirmationForm::buildForm in Auto Purge Users 8

Same name and namespace in other branches
  1. 8.3 src/Form/ConfirmationForm.php \Drupal\purge_users\Form\ConfirmationForm::buildForm()
  2. 8.2 src/Form/ConfirmationForm.php \Drupal\purge_users\Form\ConfirmationForm::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 ConfirmFormBase::buildForm

File

src/Form/ConfirmationForm.php, line 62

Class

ConfirmationForm
Class ConfirmationForm.

Namespace

Drupal\purge_users\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $accounts = NULL) {
  $form = parent::buildForm($form, $form_state);
  $uids = purge_users_get_user_ids();
  $form['accounts'] = array(
    '#prefix' => '<ul>',
    '#suffix' => '</ul>',
    '#tree' => TRUE,
  );
  $accounts = User::loadMultiple($uids);
  foreach ($accounts as $account) {

    // Prevent user 1 from being canceled.
    if ($account
      ->get('uid')->value <= 1) {
      continue;
    }
    $form['accounts']['uid' . $account
      ->get('uid')->value] = array(
      '#type' => 'markup',
      '#value' => $account
        ->get('uid')->value,
      '#prefix' => '<li>',
      '#suffix' => $account
        ->get('name')->value . " &lt;" . $account
        ->get('mail')->value . "&gt; </li>\n",
    );
  }
  return parent::buildForm($form, $form_state);
}