You are here

public function ModulesUninstallConfirmForm::buildForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Form/ModulesUninstallConfirmForm.php \Drupal\system\Form\ModulesUninstallConfirmForm::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/ModulesUninstallConfirmForm.php, line 130
Contains \Drupal\system\Form\ModulesUninstallConfirmForm.

Class

ModulesUninstallConfirmForm
Builds a confirmation form to uninstall selected modules.

Namespace

Drupal\system\Form

Code

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)) {
    drupal_set_message($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.'), 'error');
    return $this
      ->redirect('system.modules_uninstall');
  }
  $data = system_rebuild_module_data();
  $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'] = array(
    '#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->entityManager);
  return parent::buildForm($form, $form_state);
}