class ModulesUninstallConfirmForm

Builds a confirmation form to uninstall selected modules.

Used internally from system_modules_uninstall().

Hierarchy

Expanded class hierarchy of ModulesUninstallConfirmForm

1 file declares its use of ModulesUninstallConfirmForm
system.admin.inc in drupal/core/modules/system/system.admin.inc
Admin page callbacks for the system module.

File

drupal/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php, line 17
Contains \Drupal\system\Form\ModulesUninstallConfirmForm.

Namespace

Drupal\system\Form
View source
class ModulesUninstallConfirmForm extends ConfirmFormBase {

  /**
   * {@inheritdoc}
   */
  protected function getQuestion() {
    return t('Confirm uninstall');
  }

  /**
   * {@inheritdoc}
   */
  protected function getConfirmText() {
    return t('Uninstall');
  }

  /**
   * {@inheritdoc}
   */
  protected function getCancelPath() {
    return 'admin/modules/uninstall';
  }

  /**
   * {@inheritdoc}
   */
  protected function getDescription() {
    return t('Would you like to continue with uninstalling the above?');
  }

  /**
   * {@inheritdoc}
   */
  public function getFormID() {
    return 'system_modules_uninstall_confirm_form';
  }

  /**
   * {@inheritdoc}
   *
   * @param array $modules
   *   The array of modules.
   */
  public function buildForm(array $form, array &$form_state, $modules = array()) {
    $uninstall = array();

    // Construct the hidden form elements and list items.
    foreach ($modules as $module => $value) {
      $info = drupal_parse_info_file(drupal_get_path('module', $module) . '/' . $module . '.info.yml');
      $uninstall[] = $info['name'];
      $form['uninstall'][$module] = array(
        '#type' => 'hidden',
        '#value' => 1,
      );
    }
    $form['#confirmed'] = TRUE;
    $form['uninstall']['#tree'] = TRUE;
    $form['text'] = array(
      '#markup' => '<p>' . 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' => $uninstall,
    );
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, array &$form_state) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfirmFormBase::getCancelText protected function Returns a caption for the link which cancels the action. 2
ConfirmFormBase::getFormName protected function Returns the internal name used to refer to the confirmation item.
ConfirmFormBase::validateForm public function Implements \Drupal\Core\Form\FormInterface::validateForm(). Overrides FormInterface::validateForm 1
ModulesUninstallConfirmForm::buildForm public function Overrides ConfirmFormBase::buildForm
ModulesUninstallConfirmForm::getCancelPath protected function Returns the page to go to if the user cancels the action. Overrides ConfirmFormBase::getCancelPath
ModulesUninstallConfirmForm::getConfirmText protected function Returns a caption for the button that confirms the action. Overrides ConfirmFormBase::getConfirmText
ModulesUninstallConfirmForm::getDescription protected function Returns additional text to display as a description. Overrides ConfirmFormBase::getDescription
ModulesUninstallConfirmForm::getFormID public function Returns a unique string identifying the form. Overrides FormInterface::getFormID
ModulesUninstallConfirmForm::getQuestion protected function Returns the question to ask the user. Overrides ConfirmFormBase::getQuestion
ModulesUninstallConfirmForm::submitForm public function Form submission handler. Overrides FormInterface::submitForm