function ModulesUninstallConfirmForm::buildForm
Same name in other branches
- 8.9.x core/modules/system/src/Form/ModulesUninstallConfirmForm.php \Drupal\system\Form\ModulesUninstallConfirmForm::buildForm()
- 10 core/modules/system/src/Form/ModulesUninstallConfirmForm.php \Drupal\system\Form\ModulesUninstallConfirmForm::buildForm()
- 11.x core/modules/system/src/Form/ModulesUninstallConfirmForm.php \Drupal\system\Form\ModulesUninstallConfirmForm::buildForm()
Overrides ConfirmFormBase::buildForm
File
-
core/
modules/ system/ src/ Form/ ModulesUninstallConfirmForm.php, line 139
Class
- ModulesUninstallConfirmForm
- Builds a confirmation form to uninstall selected modules.
Namespace
Drupal\system\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Retrieve the list of modules from the key value store.
$account = $this->currentUser()
->id();
$this->modules = $this->keyValueExpirable
->get($account);
// Prevent this page from showing when the module list is empty.
if (empty($this->modules)) {
$this->messenger()
->addError($this->t('The selected modules could not be uninstalled, either due to a website problem or due to the uninstall confirmation form timing out. Please try again.'));
return $this->redirect('system.modules_uninstall');
}
$data = $this->moduleExtensionList
->getList();
$form['text']['#markup'] = '<p>' . $this->t('The following modules will be completely uninstalled from your site, and <em>all data from these modules will be lost</em>!') . '</p>';
$form['modules'] = [
'#theme' => 'item_list',
'#items' => array_map(function ($module) use ($data) {
return $data[$module]->info['name'];
}, $this->modules),
];
// List the dependent entities.
$this->addDependencyListsToForm($form, 'module', $this->modules, $this->configManager, $this->entityTypeManager);
return parent::buildForm($form, $form_state);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.