You are here

public function ModulesListConfirmForm::buildForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/src/Form/ModulesListConfirmForm.php \Drupal\system\Form\ModulesListConfirmForm::buildForm()
  2. 9 core/modules/system/src/Form/ModulesListConfirmForm.php \Drupal\system\Form\ModulesListConfirmForm::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

core/modules/system/src/Form/ModulesListConfirmForm.php, line 117

Class

ModulesListConfirmForm
Builds a confirmation form for enabling modules with dependencies.

Namespace

Drupal\system\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $account = $this
    ->currentUser()
    ->id();
  $this->modules = $this->keyValueExpirable
    ->get($account);

  // Redirect to the modules list page if the key value store is empty.
  if (!$this->modules) {
    return $this
      ->redirect('system.modules_list');
  }
  $items = $this
    ->buildMessageList();
  $form['message'] = [
    '#theme' => 'item_list',
    '#items' => $items,
  ];
  return parent::buildForm($form, $form_state);
}