function ModulesUninstallConfirmForm::buildForm
Same name in other branches
- 9 core/modules/system/src/Form/ModulesUninstallConfirmForm.php \Drupal\system\Form\ModulesUninstallConfirmForm::buildForm()
- 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()
Overrides ConfirmFormBase::buildForm
File
-
core/
modules/ system/ src/ Form/ ModulesUninstallConfirmForm.php, line 143
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.'));
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),
];
if (!empty($this->installProfile) && in_array($this->installProfile, $this->modules, TRUE)) {
$form['profile']['#markup'] = '<p>' . $this->t('Once uninstalled, the %install_profile profile cannot be reinstalled.', [
'%install_profile' => $data[$this->installProfile]->info['name'],
]) . '</p>';
}
// 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.