diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php new file mode 100644 index 0000000..f66c361 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php @@ -0,0 +1,141 @@ +loadInclude('system', 'inc', 'system.admin'); + if ($confirm_form = system_modules_uninstall_confirm_form($form_state['storage'])) { + return $confirm_form; + } + } + + // Get a list of disabled, installed modules. + $all_modules = system_rebuild_module_data(); + $disabled_modules = array(); + foreach ($all_modules as $name => $module) { + if (empty($module->status) && drupal_get_installed_schema_version($name) > SCHEMA_UNINSTALLED) { + $disabled_modules[$name] = $module; + } + } + + // Only build the rest of the form if there are any modules available to + // uninstall. + if (!empty($disabled_modules)) { + $profile = drupal_get_profile(); + \Drupal::moduleHandler()->loadInclude('system', 'inc', 'system.admin'); + uasort($disabled_modules, 'system_sort_modules_by_info_name'); + $form['uninstall'] = array('#tree' => TRUE); + foreach ($disabled_modules as $module) { + $module_name = $module->info['name'] ? $module->info['name'] : $module->name; + $form['modules'][$module->name]['#module_name'] = $module_name; + $form['modules'][$module->name]['name']['#markup'] = $module_name; + $form['modules'][$module->name]['description']['#markup'] = t($module->info['description']); + $form['uninstall'][$module->name] = array( + '#type' => 'checkbox', + '#title' => t('Uninstall @module module', array('@module' => $module_name)), + '#title_display' => 'invisible', + ); + // All modules which depend on this one must be uninstalled first, before + // we can allow this module to be uninstalled. (The installation profile + // is excluded from this list.) + foreach (array_keys($module->required_by) as $dependent) { + if ($dependent != $profile && drupal_get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED) { + $dependent_name = isset($all_modules[$dependent]->info['name']) ? $all_modules[$dependent]->info['name'] : $dependent; + $form['modules'][$module->name]['#required_by'][] = $dependent_name; + $form['uninstall'][$module->name]['#disabled'] = TRUE; + } + } + } + $form['actions'] = array('#type' => 'actions'); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Uninstall'), + ); + $form['#action'] = url('admin/modules/uninstall/confirm'); + } + else { + $form['modules'] = array(); + } + + return $form; + } + + /** + * {@inheritdoc} + */ + public function validateForm(array &$form, array &$form_state) { + // Form submitted, but no modules selected. + if (!count(array_filter($form_state['values']['uninstall']))) { + drupal_set_message(t('No modules selected.'), 'error'); + drupal_goto('admin/modules/uninstall'); + } + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, array &$form_state) { + // Make sure the install API is available. + include_once DRUPAL_ROOT . '/core/includes/install.inc'; + + if (!empty($form['#confirmed'])) { + // Call the uninstall routine for each selected module. + $modules = array_keys($form_state['values']['uninstall']); + module_uninstall($modules); + drupal_set_message(t('The selected modules have been uninstalled.')); + + $form_state['redirect'] = 'admin/modules/uninstall'; + } + else { + $form_state['storage'] = $form_state['values']; + $form_state['rebuild'] = TRUE; + } + } +} diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index c6002f9..a1b8291 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1272,76 +1272,6 @@ function system_modules_submit($form, &$form_state) { */ /** - * Builds a form of currently disabled modules. - * - * @ingroup forms - * @see system_modules_uninstall_validate() - * @see system_modules_uninstall_submit() - * @param $form_state['values'] - * Submitted form values. - * @return - * A form array representing the currently disabled modules. - */ -function system_modules_uninstall($form, $form_state = NULL) { - // Make sure the install API is available. - include_once DRUPAL_ROOT . '/core/includes/install.inc'; - - // Display the confirm form if any modules have been submitted. - if (!empty($form_state['storage']) && $confirm_form = system_modules_uninstall_confirm_form($form_state['storage'])) { - return $confirm_form; - } - - // Get a list of disabled, installed modules. - $all_modules = system_rebuild_module_data(); - $disabled_modules = array(); - foreach ($all_modules as $name => $module) { - if (empty($module->status) && drupal_get_installed_schema_version($name) > SCHEMA_UNINSTALLED) { - $disabled_modules[$name] = $module; - } - } - - // Only build the rest of the form if there are any modules available to - // uninstall. - if (!empty($disabled_modules)) { - $profile = drupal_get_profile(); - uasort($disabled_modules, 'system_sort_modules_by_info_name'); - $form['uninstall'] = array('#tree' => TRUE); - foreach ($disabled_modules as $module) { - $module_name = $module->info['name'] ? $module->info['name'] : $module->name; - $form['modules'][$module->name]['#module_name'] = $module_name; - $form['modules'][$module->name]['name']['#markup'] = $module_name; - $form['modules'][$module->name]['description']['#markup'] = t($module->info['description']); - $form['uninstall'][$module->name] = array( - '#type' => 'checkbox', - '#title' => t('Uninstall @module module', array('@module' => $module_name)), - '#title_display' => 'invisible', - ); - // All modules which depend on this one must be uninstalled first, before - // we can allow this module to be uninstalled. (The installation profile - // is excluded from this list.) - foreach (array_keys($module->required_by) as $dependent) { - if ($dependent != $profile && drupal_get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED) { - $dependent_name = isset($all_modules[$dependent]->info['name']) ? $all_modules[$dependent]->info['name'] : $dependent; - $form['modules'][$module->name]['#required_by'][] = $dependent_name; - $form['uninstall'][$module->name]['#disabled'] = TRUE; - } - } - } - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( - '#type' => 'submit', - '#value' => t('Uninstall'), - ); - $form['#action'] = url('admin/modules/uninstall/confirm'); - } - else { - $form['modules'] = array(); - } - - return $form; -} - -/** * Confirm uninstall of selected modules. * * @ingroup forms @@ -1383,38 +1313,6 @@ function system_modules_uninstall_confirm_form($storage) { } /** - * Validates the submitted uninstall form. - */ -function system_modules_uninstall_validate($form, &$form_state) { - // Form submitted, but no modules selected. - if (!count(array_filter($form_state['values']['uninstall']))) { - drupal_set_message(t('No modules selected.'), 'error'); - drupal_goto('admin/modules/uninstall'); - } -} - -/** - * Processes the submitted uninstall form. - */ -function system_modules_uninstall_submit($form, &$form_state) { - // Make sure the install API is available. - include_once DRUPAL_ROOT . '/core/includes/install.inc'; - - if (!empty($form['#confirmed'])) { - // Call the uninstall routine for each selected module. - $modules = array_keys($form_state['values']['uninstall']); - module_uninstall($modules); - drupal_set_message(t('The selected modules have been uninstalled.')); - - $form_state['redirect'] = 'admin/modules/uninstall'; - } - else { - $form_state['storage'] = $form_state['values']; - $form_state['rebuild'] = TRUE; - } -} - -/** * Form builder; The general site information form. * * @ingroup forms diff --git a/core/modules/system/system.module b/core/modules/system/system.module index c75309c..94cbd2b 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -771,17 +771,16 @@ function system_menu() { ); $items['admin/modules/uninstall'] = array( 'title' => 'Uninstall', - 'page arguments' => array('system_modules_uninstall'), - 'access arguments' => array('administer modules'), + 'route name' => 'system_modules_uninstall', + 'page callback' => 'USES ROUTE', + 'access callback' => TRUE, 'type' => MENU_LOCAL_TASK, - 'file' => 'system.admin.inc', 'weight' => 20, ); $items['admin/modules/uninstall/confirm'] = array( 'title' => 'Uninstall', - 'access arguments' => array('administer modules'), + 'route name' => 'system_modules_uninstall_confirm', 'type' => MENU_VISIBLE_IN_BREADCRUMB, - 'file' => 'system.admin.inc', ); // Configuration. diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index 69a3eae..349c7fa 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -4,9 +4,25 @@ system.cron: _controller: '\Drupal\system\CronController::run' requirements: _access_system_cron: 'TRUE' + system.machine_name_transliterate: pattern: '/machine_name/transliterate' defaults: _controller: '\Drupal\system\MachineNameController::transliterate' requirements: _permission: 'access content' + +system_modules_uninstall: + pattern: 'admin/modules/uninstall' + defaults: + _form: 'Drupal\system\Form\ModulesUninstallForm' + requirements: + _permission: 'administer modules' + +system_modules_uninstall_confirm: + pattern: 'admin/modules/uninstall/confirm' + defaults: + _form: 'Drupal\system\Form\ModulesUninstallForm' + requirements: + _permission: 'administer modules' +