diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php
new file mode 100644
index 0000000..e9ad702
--- /dev/null
+++ b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php
@@ -0,0 +1,471 @@
+get('module_handler')
+ );
+ }
+
+ /**
+ * Constructs a ModulesListForm object.
+ *
+ * @param ModuleHandlerInterface $module_handler
+ * A module handler.
+ */
+ public function __construct(ModuleHandlerInterface $module_handler) {
+ $this->moduleHandler = $module_handler;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormID() {
+ return 'system_modules';
+ }
+
+ /**
+ * Form builder; provides module enable/disable interface.
+ *
+ * The list of modules gets populated by module.info.yml files, which contain
+ * each module's name, description, and information about which modules it
+ * requires.
+ * See drupal_parse_info_file() for infos on module.info.yml descriptors.
+ *
+ * Dependency checking is performed to ensure that a module:
+ * - can not be enabled if there are disabled modules it requires.
+ * - can not be disabled if there are enabled modules which depend on it.
+ *
+ * {@inheritdoc}
+ *
+ * @return
+ * The form array.
+ *
+ * @see theme_system_modules()
+ *
+ * @ingroup forms
+ */
+ public function buildForm(array $form, array &$form_state) {
+ // Get current list of modules.
+ $files = system_rebuild_module_data();
+
+ // Remove hidden modules from display list.
+ $visible_files = $files;
+ foreach ($visible_files as $filename => $file) {
+ if (!empty($file->info['hidden'])) {
+ unset($visible_files[$filename]);
+ }
+ }
+
+ $this->moduleHandler->loadInclude('system', 'inc', 'system.admin');
+ uasort($visible_files, 'system_sort_modules_by_info_name');
+
+ // If the modules form was submitted, then submitForm() runs first and if
+ // there are unfilled required modules, then $form_state['storage'] is
+ // filled, triggering a rebuild. In this case we need to display a
+ // confirmation form.
+ if (!empty($form_state['storage'])) {
+ // Contents of confirm form is injected here because already in form
+ // building function.
+ $confirm_form = new ModulesInstallConfirmForm();
+ return $confirm_form->buildForm($form, $form_state, $visible_files, $form_state['storage']);
+ }
+
+ // JS-only table filters.
+ $form['filters'] = array(
+ '#type' => 'container',
+ '#attributes' => array(
+ 'class' => array('table-filter', 'js-show'),
+ ),
+ );
+ $form['filters']['text'] = array(
+ '#type' => 'search',
+ '#title' => t('Search'),
+ '#size' => 30,
+ '#placeholder' => t('Enter module name…'),
+ '#attributes' => array(
+ 'class' => array('table-filter-text'),
+ 'data-table' => '#system-modules',
+ 'autocomplete' => 'off',
+ 'title' => t('Enter a part of the module name or description to filter by.'),
+ ),
+ );
+
+ $modules = array();
+ $form['modules'] = array('#tree' => TRUE);
+
+ // Used when checking if module implements a help page.
+ $help_arg = module_exists('help') ? drupal_help_arg() : FALSE;
+
+ // Used when displaying modules that are required by the installation profile.
+ require_once DRUPAL_ROOT . '/core/includes/install.inc';
+ $distribution_name = String::checkPlain(drupal_install_profile_distribution_name());
+
+ // Iterate through each of the modules.
+ foreach ($visible_files as $filename => $module) {
+ $extra = array();
+ $extra['enabled'] = (bool) $module->status;
+ if (!empty($module->info['required'] )) {
+ $extra['disabled'] = TRUE;
+ $extra['required_by'][] = $distribution_name . (!empty($module->info['explanation']) ? ' ('. $module->info['explanation'] .')' : '');
+ }
+
+ // If this module requires other modules, add them to the array.
+ foreach ($module->requires as $requires => $v) {
+ if (!isset($files[$requires])) {
+ $extra['requires'][$requires] = t('@module (missing)', array('@module' => Unicode::ucfirst($requires)));
+ $extra['disabled'] = TRUE;
+ }
+ // Only display visible modules.
+ elseif (isset($visible_files[$requires])) {
+ $requires_name = $files[$requires]->info['name'];
+ // Disable this module if it is incompatible with the dependency's version.
+ if ($incompatible_version = drupal_check_incompatibility($v, str_replace(DRUPAL_CORE_COMPATIBILITY . '-', '', $files[$requires]->info['version']))) {
+ $extra['requires'][$requires] = t('@module (incompatible with version @version)', array(
+ '@module' => $requires_name . $incompatible_version,
+ '@version' => $files[$requires]->info['version'],
+ ));
+ $extra['disabled'] = TRUE;
+ }
+ // Disable this module if the dependency is incompatible with this
+ // version of Drupal core.
+ elseif ($files[$requires]->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
+ $extra['requires'][$requires] = t('@module (incompatible with this version of Drupal core)', array(
+ '@module' => $requires_name,
+ ));
+ $extra['disabled'] = TRUE;
+ }
+ elseif ($files[$requires]->status) {
+ $extra['requires'][$requires] = t('@module', array('@module' => $requires_name));
+ }
+ else {
+ $extra['requires'][$requires] = t('@module (disabled)', array('@module' => $requires_name));
+ }
+ }
+ }
+ // Generate link for module's help page, if there is one.
+ if ($help_arg && $module->status && in_array($filename, $this->moduleHandler->getImplementations('help'))) {
+ if ($this->moduleHandler->invoke($filename, 'help', array("admin/help#$filename", $help_arg))) {
+ $extra['links']['help'] = array(
+ '#type' => 'link',
+ '#title' => t('Help'),
+ '#href' => "admin/help/$filename",
+ '#options' => array('attributes' => array('class' => array('module-link', 'module-link-help'), 'title' => t('Help'))),
+ );
+ }
+ }
+ // Generate link for module's permission, if the user has access to it.
+ if ($module->status && user_access('administer permissions') && in_array($filename, $this->moduleHandler->getImplementations('permission'))) {
+ $extra['links']['permissions'] = array(
+ '#type' => 'link',
+ '#title' => t('Permissions'),
+ '#href' => 'admin/people/permissions',
+ '#options' => array('fragment' => 'module-' . $filename, 'attributes' => array('class' => array('module-link', 'module-link-permissions'), 'title' => t('Configure permissions'))),
+ );
+ }
+ // Generate link for module's configuration page, if the module provides
+ // one.
+ if ($module->status && isset($module->info['configure'])) {
+ $configure_link = menu_get_item($module->info['configure']);
+ if ($configure_link['access']) {
+ $extra['links']['configure'] = array(
+ '#type' => 'link',
+ '#title' => t('Configure'),
+ '#href' => $configure_link['href'],
+ '#options' => array('attributes' => array('class' => array('module-link', 'module-link-configure'), 'title' => $configure_link['description'])),
+ );
+ }
+ }
+
+ // If this module is required by other modules, list those, and then make it
+ // impossible to disable this one.
+ foreach ($module->required_by as $required_by => $v) {
+ // Hidden modules are unset already.
+ if (isset($visible_files[$required_by])) {
+ if ($files[$required_by]->status == 1 && $module->status == 1) {
+ $extra['required_by'][] = t('@module', array('@module' => $files[$required_by]->info['name']));
+ $extra['disabled'] = TRUE;
+ }
+ else {
+ $extra['required_by'][] = t('@module (disabled)', array('@module' => $files[$required_by]->info['name']));
+ }
+ }
+ }
+ $form['modules'][$module->info['package']][$filename] = $this->buildRow($module->info, $extra);
+ }
+
+ // Add basic information to the details.
+ foreach (element_children($form['modules']) as $package) {
+ $form['modules'][$package] += array(
+ '#type' => 'details',
+ '#title' => t($package),
+ '#theme' => 'system_modules_details',
+ '#header' => array(
+ array('data' => t('Enabled'), 'class' => array('checkbox')),
+ array('data' => t('Name'), 'class' => array('name')),
+ array('data' => t('Description'), 'class' => array('description', RESPONSIVE_PRIORITY_LOW)),
+ ),
+ // Ensure that the "Core" package comes first.
+ '#weight' => $package == 'Core' ? -10 : NULL,
+ );
+ }
+ // Lastly, sort all packages by title.
+ uasort($form['modules'], 'element_sort_by_title');
+
+ $form['#attached']['library'][] = array('system', 'drupal.system.modules');
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save configuration'),
+ );
+ $form['#action'] = url('admin/modules/list/confirm');
+
+ return $form;
+ }
+
+ /**
+ * Build a table row for the system modules page.
+ */
+ private function buildRow($info, $extra) {
+ // Add in the defaults.
+ $extra += array(
+ 'requires' => array(),
+ 'required_by' => array(),
+ 'disabled' => FALSE,
+ 'enabled' => FALSE,
+ 'links' => array(),
+ );
+ $form = array(
+ '#tree' => TRUE,
+ );
+ // Set the basic properties.
+ $form['name'] = array(
+ '#markup' => $info['name'],
+ );
+ $form['description'] = array(
+ '#markup' => t($info['description']),
+ );
+ $form['version'] = array(
+ '#markup' => $info['version'],
+ );
+ $form['#requires'] = $extra['requires'];
+ $form['#required_by'] = $extra['required_by'];
+
+ // Check the compatibilities.
+ $compatible = TRUE;
+ $status_short = '';
+ $status_long = '';
+
+ // Check the core compatibility.
+ if (!isset($info['core']) || $info['core'] != DRUPAL_CORE_COMPATIBILITY) {
+ $compatible = FALSE;
+ $status_short .= t('Incompatible with this version of Drupal core.');
+ $status_long .= t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => DRUPAL_CORE_COMPATIBILITY));
+ }
+
+ // Ensure this module is compatible with the currently installed version of PHP.
+ if (version_compare(phpversion(), $info['php']) < 0) {
+ $compatible = FALSE;
+ $status_short .= t('Incompatible with this version of PHP');
+ $php_required = $info['php'];
+ if (substr_count($info['php'], '.') < 2) {
+ $php_required .= '.*';
+ }
+ $status_long .= t('This module requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion()));
+ }
+
+ // If this module is compatible, present a checkbox indicating
+ // this module may be installed. Otherwise, show a big red X.
+ if ($compatible) {
+ $form['enable'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable'),
+ '#default_value' => $extra['enabled'],
+ '#attributes' => array('role' => 'disabled'),
+ );
+ if ($extra['disabled']) {
+ $form['enable']['#disabled'] = TRUE;
+ }
+ }
+ else {
+ $form['enable'] = array(
+ '#markup' => theme('image', array('uri' => 'core/misc/watchdog-error.png', 'alt' => $status_short, 'title' => $status_short)),
+ );
+ $form['description']['#markup'] .= theme('system_modules_incompatible', array('message' => $status_long));
+ }
+
+ // Build operation links.
+ foreach (array('help', 'permissions', 'configure') as $key) {
+ $form['links'][$key] = (isset($extra['links'][$key]) ? $extra['links'][$key] : array());
+ }
+
+ return $form;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function validateForm(array &$form, array &$form_state) {
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function submitForm(array &$form, array &$form_state) {
+ include_once DRUPAL_ROOT . '/core/includes/install.inc';
+
+ // Builds list of modules.
+ $modules = array();
+ // If we're not coming from the confirmation form, build the list of modules.
+ if (empty($form_state['storage'])) {
+ // If we're not coming from the confirmation form, build the module list.
+ foreach ($form_state['values']['modules'] as $group_name => $group) {
+ foreach ($group as $module => $enabled) {
+ $modules[$module] = array('group' => $group_name, 'enabled' => $enabled['enable']);
+ }
+ }
+ }
+ else {
+ // If we are coming from the confirmation form, fetch
+ // the modules out of $form_state.
+ $modules = $form_state['storage']['modules'];
+ }
+
+ // Collect data for all modules to be able to determine dependencies.
+ $files = system_rebuild_module_data();
+
+ // Sorts modules by weight.
+ $sort = array();
+ foreach (array_keys($modules) as $module) {
+ $sort[$module] = $files[$module]->sort;
+ }
+ array_multisort($sort, $modules);
+
+ // Makes sure all required modules are set to be enabled.
+ $more_required = array();
+ $missing_modules = array();
+ foreach ($modules as $name => $module) {
+ if ($module['enabled']) {
+ // Checks that all dependencies are set to be enabled. Stores the ones
+ // that are not in $dependencies variable so that the user can be alerted
+ // in the confirmation form that more modules need to be enabled.
+ $dependencies = array();
+ foreach (array_keys($files[$name]->requires) as $required) {
+ if (empty($modules[$required]['enabled'])) {
+ if (isset($files[$required])) {
+ $dependencies[] = $files[$required]->info['name'];
+ $modules[$required]['enabled'] = TRUE;
+ }
+ else {
+ $missing_modules[$required]['depends'][] = $name;
+ $modules[$name]['enabled'] = FALSE;
+ }
+ }
+ }
+
+ // Stores additional modules that need to be enabled in $more_required.
+ if (!empty($dependencies)) {
+ $more_required[$name] = array(
+ 'name' => $files[$name]->info['name'],
+ 'requires' => $dependencies,
+ );
+ }
+ }
+ }
+
+ // Redirects to confirmation form if more modules need to be enabled.
+ if ((!empty($more_required) || !empty($missing_modules)) && !isset($form_state['values']['confirm'])) {
+ $form_state['storage'] = array(
+ 'more_required' => $more_required,
+ 'modules' => $modules,
+ 'missing_modules' => $missing_modules,
+ );
+ $form_state['rebuild'] = TRUE;
+ return;
+ }
+
+ // Invokes hook_requirements('install'). If failures are detected, makes sure
+ // the dependent modules aren't installed either.
+ foreach ($modules as $name => $module) {
+ // Only invoke hook_requirements() on modules that are going to be installed.
+ if ($module['enabled'] && drupal_get_installed_schema_version($name) == SCHEMA_UNINSTALLED) {
+ if (!drupal_check_module($name)) {
+ $modules[$name]['enabled'] = FALSE;
+ foreach (array_keys($files[$name]->required_by) as $required_by) {
+ $modules[$required_by]['enabled'] = FALSE;
+ }
+ }
+ }
+ }
+
+ // Initializes array of actions.
+ $actions = array(
+ 'enable' => array(),
+ 'disable' => array(),
+ 'install' => array(),
+ );
+
+ // Builds arrays of modules that need to be enabled, disabled, and installed.
+ foreach ($modules as $name => $module) {
+ if ($module['enabled']) {
+ if (drupal_get_installed_schema_version($name) == SCHEMA_UNINSTALLED) {
+ $actions['install'][] = $name;
+ $actions['enable'][] = $name;
+ }
+ elseif (!module_exists($name)) {
+ $actions['enable'][] = $name;
+ }
+ }
+ elseif (module_exists($name)) {
+ $actions['disable'][] = $name;
+ }
+ }
+
+ // Gets list of modules prior to install process, unsets $form_state['storage']
+ // so we don't get redirected back to the confirmation form.
+ $pre_install_list = drupal_container()->get('module_handler')->getModuleList();
+ unset($form_state['storage']);
+
+ // Reverse the 'enable' list, to order dependencies before dependents.
+ krsort($actions['enable']);
+
+ // Installs, enables, and disables modules.
+ module_enable($actions['enable'], FALSE);
+ module_disable($actions['disable'], FALSE);
+
+ // Gets module list after install process, flushes caches and displays a
+ // message if there are changes.
+ $post_install_list = $this->moduleHandler->getModuleList();
+ if ($pre_install_list != $post_install_list) {
+ drupal_flush_all_caches();
+ drupal_set_message(t('The configuration options have been saved.'));
+ }
+
+ $form_state['redirect'] = 'admin/modules';
+ }
+
+}
diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc
index 957db86..ef7e64a 100644
--- a/core/modules/system/system.admin.inc
+++ b/core/modules/system/system.admin.inc
@@ -333,202 +333,6 @@ function _system_is_incompatible(&$incompatible, $files, $file) {
}
/**
- * Form constructor for the module enable/disable interface.
- *
- * The list of modules gets populated by module.info.yml files, which contain
- * each module's name, description, and information about which modules it
- * requires.
- * See drupal_parse_info_file() for information on module.info.yml descriptors.
- *
- * Dependency checking is performed to ensure that a module:
- * - can not be enabled if there are disabled modules it requires.
- * - can not be disabled if there are enabled modules which depend on it.
- *
- * @see system_menu()
- * @see theme_system_modules()
- * @see system_modules_submit()
- *
- * @ingroup forms
- */
-function system_modules($form, $form_state = array()) {
- // Get current list of modules.
- $files = system_rebuild_module_data();
-
- // Remove hidden modules from display list.
- $visible_files = $files;
- foreach ($visible_files as $filename => $file) {
- if (!empty($file->info['hidden'])) {
- unset($visible_files[$filename]);
- }
- }
-
- uasort($visible_files, 'system_sort_modules_by_info_name');
-
- // If the modules form was submitted, then system_modules_submit() runs first
- // and if there are unfilled required modules, then $form_state['storage'] is
- // filled, triggering a rebuild. In this case we need to display a
- // confirmation form.
- if (!empty($form_state['storage'])) {
- // Contents of confirm form is injected here because already in form
- // building function.
- $confirm_form = new ModulesInstallConfirmForm();
- return $confirm_form->buildForm($form, $form_state, $visible_files, $form_state['storage'], Drupal::request());
- }
-
- // JS-only table filters.
- $form['filters'] = array(
- '#type' => 'container',
- '#attributes' => array(
- 'class' => array('table-filter', 'js-show'),
- ),
- );
- $form['filters']['text'] = array(
- '#type' => 'search',
- '#title' => t('Search'),
- '#size' => 30,
- '#placeholder' => t('Enter module name…'),
- '#attributes' => array(
- 'class' => array('table-filter-text'),
- 'data-table' => '#system-modules',
- 'autocomplete' => 'off',
- 'title' => t('Enter a part of the module name or description to filter by.'),
- ),
- );
-
- $modules = array();
- $form['modules'] = array('#tree' => TRUE);
-
- // Used when checking if module implements a help page.
- $help_arg = module_exists('help') ? drupal_help_arg() : FALSE;
-
- // Used when displaying modules that are required by the installation profile.
- require_once DRUPAL_ROOT . '/core/includes/install.inc';
- $distribution_name = check_plain(drupal_install_profile_distribution_name());
-
- // Iterate through each of the modules.
- foreach ($visible_files as $filename => $module) {
- $extra = array();
- $extra['enabled'] = (bool) $module->status;
- if (!empty($module->info['required'] )) {
- $extra['disabled'] = TRUE;
- $extra['required_by'][] = $distribution_name . (!empty($module->info['explanation']) ? ' ('. $module->info['explanation'] .')' : '');
- }
-
- // If this module requires other modules, add them to the array.
- foreach ($module->requires as $requires => $v) {
- if (!isset($files[$requires])) {
- $extra['requires'][$requires] = t('@module (missing)', array('@module' => drupal_ucfirst($requires)));
- $extra['disabled'] = TRUE;
- }
- // Only display visible modules.
- elseif (isset($visible_files[$requires])) {
- $requires_name = $files[$requires]->info['name'];
- // Disable this module if it is incompatible with the dependency's version.
- if ($incompatible_version = drupal_check_incompatibility($v, str_replace(DRUPAL_CORE_COMPATIBILITY . '-', '', $files[$requires]->info['version']))) {
- $extra['requires'][$requires] = t('@module (incompatible with version @version)', array(
- '@module' => $requires_name . $incompatible_version,
- '@version' => $files[$requires]->info['version'],
- ));
- $extra['disabled'] = TRUE;
- }
- // Disable this module if the dependency is incompatible with this
- // version of Drupal core.
- elseif ($files[$requires]->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
- $extra['requires'][$requires] = t('@module (incompatible with this version of Drupal core)', array(
- '@module' => $requires_name,
- ));
- $extra['disabled'] = TRUE;
- }
- elseif ($files[$requires]->status) {
- $extra['requires'][$requires] = t('@module', array('@module' => $requires_name));
- }
- else {
- $extra['requires'][$requires] = t('@module (disabled)', array('@module' => $requires_name));
- }
- }
- }
- // Generate link for module's help page, if there is one.
- if ($help_arg && $module->status && in_array($filename, module_implements('help'))) {
- if (module_invoke($filename, 'help', "admin/help#$filename", $help_arg)) {
- $extra['links']['help'] = array(
- '#type' => 'link',
- '#title' => t('Help'),
- '#href' => "admin/help/$filename",
- '#options' => array('attributes' => array('class' => array('module-link', 'module-link-help'), 'title' => t('Help'))),
- );
- }
- }
- // Generate link for module's permission, if the user has access to it.
- if ($module->status && user_access('administer permissions') && in_array($filename, module_implements('permission'))) {
- $extra['links']['permissions'] = array(
- '#type' => 'link',
- '#title' => t('Permissions'),
- '#href' => 'admin/people/permissions',
- '#options' => array('fragment' => 'module-' . $filename, 'attributes' => array('class' => array('module-link', 'module-link-permissions'), 'title' => t('Configure permissions'))),
- );
- }
- // Generate link for module's configuration page, if the module provides
- // one.
- if ($module->status && isset($module->info['configure'])) {
- $configure_link = menu_get_item($module->info['configure']);
- if ($configure_link['access']) {
- $extra['links']['configure'] = array(
- '#type' => 'link',
- '#title' => t('Configure'),
- '#href' => $configure_link['href'],
- '#options' => array('attributes' => array('class' => array('module-link', 'module-link-configure'), 'title' => $configure_link['description'])),
- );
- }
- }
-
- // If this module is required by other modules, list those, and then make it
- // impossible to disable this one.
- foreach ($module->required_by as $required_by => $v) {
- // Hidden modules are unset already.
- if (isset($visible_files[$required_by])) {
- if ($files[$required_by]->status == 1 && $module->status == 1) {
- $extra['required_by'][] = t('@module', array('@module' => $files[$required_by]->info['name']));
- $extra['disabled'] = TRUE;
- }
- else {
- $extra['required_by'][] = t('@module (disabled)', array('@module' => $files[$required_by]->info['name']));
- }
- }
- }
- $form['modules'][$module->info['package']][$filename] = _system_modules_build_row($module->info, $extra);
- }
-
- // Add basic information to the details.
- foreach (element_children($form['modules']) as $package) {
- $form['modules'][$package] += array(
- '#type' => 'details',
- '#title' => t($package),
- '#theme' => 'system_modules_details',
- '#header' => array(
- array('data' => t('Enabled'), 'class' => array('checkbox')),
- array('data' => t('Name'), 'class' => array('name')),
- array('data' => t('Description'), 'class' => array('description', RESPONSIVE_PRIORITY_LOW)),
- ),
- // Ensure that the "Core" package comes first.
- '#weight' => $package == 'Core' ? -10 : NULL,
- );
- }
-
- // Lastly, sort all packages by title.
- uasort($form['modules'], 'element_sort_by_title');
-
- $form['#attached']['library'][] = array('system', 'drupal.system.modules');
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Save configuration'),
- );
- $form['#action'] = url('admin/modules/list/confirm');
-
- return $form;
-}
-
-/**
* Array sorting callback; sorts modules or themes by their name.
*/
function system_sort_modules_by_info_name($a, $b) {
@@ -549,221 +353,6 @@ function system_sort_themes($a, $b) {
}
/**
- * Build a table row for the system modules page.
- */
-function _system_modules_build_row($info, $extra) {
- // Add in the defaults.
- $extra += array(
- 'requires' => array(),
- 'required_by' => array(),
- 'disabled' => FALSE,
- 'enabled' => FALSE,
- 'links' => array(),
- );
- $form = array(
- '#tree' => TRUE,
- );
- // Set the basic properties.
- $form['name'] = array(
- '#markup' => $info['name'],
- );
- $form['description'] = array(
- '#markup' => t($info['description']),
- );
- $form['version'] = array(
- '#markup' => $info['version'],
- );
- $form['#requires'] = $extra['requires'];
- $form['#required_by'] = $extra['required_by'];
-
- // Check the compatibilities.
- $compatible = TRUE;
- $status_short = '';
- $status_long = '';
-
- // Check the core compatibility.
- if (!isset($info['core']) || $info['core'] != DRUPAL_CORE_COMPATIBILITY) {
- $compatible = FALSE;
- $status_short .= t('Incompatible with this version of Drupal core.');
- $status_long .= t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => DRUPAL_CORE_COMPATIBILITY));
- }
-
- // Ensure this module is compatible with the currently installed version of PHP.
- if (version_compare(phpversion(), $info['php']) < 0) {
- $compatible = FALSE;
- $status_short .= t('Incompatible with this version of PHP');
- $php_required = $info['php'];
- if (substr_count($info['php'], '.') < 2) {
- $php_required .= '.*';
- }
- $status_long .= t('This module requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion()));
- }
-
- // If this module is compatible, present a checkbox indicating
- // this module may be installed. Otherwise, show a big red X.
- if ($compatible) {
- $form['enable'] = array(
- '#type' => 'checkbox',
- '#title' => t('Enable'),
- '#default_value' => $extra['enabled'],
- '#attributes' => array('role' => 'disabled'),
- );
- if ($extra['disabled']) {
- $form['enable']['#disabled'] = TRUE;
- }
- }
- else {
- $form['enable'] = array(
- '#markup' => theme('image', array('uri' => 'core/misc/watchdog-error.png', 'alt' => $status_short, 'title' => $status_short)),
- );
- $form['description']['#markup'] .= theme('system_modules_incompatible', array('message' => $status_long));
- }
-
- // Build operation links.
- foreach (array('help', 'permissions', 'configure') as $key) {
- $form['links'][$key] = (isset($extra['links'][$key]) ? $extra['links'][$key] : array());
- }
-
- return $form;
-}
-
-/**
- * Submit callback; handles modules form submission.
- */
-function system_modules_submit($form, &$form_state) {
- include_once DRUPAL_ROOT . '/core/includes/install.inc';
-
- // Builds list of modules.
- $modules = array();
- // If we're not coming from the confirmation form, build the list of modules.
- if (empty($form_state['storage'])) {
- // If we're not coming from the confirmation form, build the module list.
- foreach ($form_state['values']['modules'] as $group_name => $group) {
- foreach ($group as $module => $enabled) {
- $modules[$module] = array('group' => $group_name, 'enabled' => $enabled['enable']);
- }
- }
- }
- else {
- // If we are coming from the confirmation form, fetch
- // the modules out of $form_state.
- $modules = $form_state['storage']['modules'];
- }
-
- // Collect data for all modules to be able to determine dependencies.
- $files = system_rebuild_module_data();
-
- // Sorts modules by weight.
- $sort = array();
- foreach (array_keys($modules) as $module) {
- $sort[$module] = $files[$module]->sort;
- }
- array_multisort($sort, $modules);
-
- // Makes sure all required modules are set to be enabled.
- $more_required = array();
- $missing_modules = array();
- foreach ($modules as $name => $module) {
- if ($module['enabled']) {
- // Checks that all dependencies are set to be enabled. Stores the ones
- // that are not in $dependencies variable so that the user can be alerted
- // in the confirmation form that more modules need to be enabled.
- $dependencies = array();
- foreach (array_keys($files[$name]->requires) as $required) {
- if (empty($modules[$required]['enabled'])) {
- if (isset($files[$required])) {
- $dependencies[] = $files[$required]->info['name'];
- $modules[$required]['enabled'] = TRUE;
- }
- else {
- $missing_modules[$required]['depends'][] = $name;
- $modules[$name]['enabled'] = FALSE;
- }
- }
- }
-
- // Stores additional modules that need to be enabled in $more_required.
- if (!empty($dependencies)) {
- $more_required[$name] = array(
- 'name' => $files[$name]->info['name'],
- 'requires' => $dependencies,
- );
- }
- }
- }
-
- // Redirects to confirmation form if more modules need to be enabled.
- if ((!empty($more_required) || !empty($missing_modules)) && !isset($form_state['values']['confirm'])) {
- $form_state['storage'] = array(
- 'more_required' => $more_required,
- 'modules' => $modules,
- 'missing_modules' => $missing_modules,
- );
- $form_state['rebuild'] = TRUE;
- return;
- }
-
- // Invokes hook_requirements('install'). If failures are detected, makes sure
- // the dependent modules aren't installed either.
- foreach ($modules as $name => $module) {
- // Only invoke hook_requirements() on modules that are going to be installed.
- if ($module['enabled'] && drupal_get_installed_schema_version($name) == SCHEMA_UNINSTALLED) {
- if (!drupal_check_module($name)) {
- $modules[$name]['enabled'] = FALSE;
- foreach (array_keys($files[$name]->required_by) as $required_by) {
- $modules[$required_by]['enabled'] = FALSE;
- }
- }
- }
- }
-
- // Initializes array of actions.
- $actions = array(
- 'enable' => array(),
- 'disable' => array(),
- 'install' => array(),
- );
-
- // Builds arrays of modules that need to be enabled, disabled, and installed.
- foreach ($modules as $name => $module) {
- if ($module['enabled']) {
- if (drupal_get_installed_schema_version($name) == SCHEMA_UNINSTALLED) {
- $actions['install'][] = $name;
- $actions['enable'][] = $name;
- }
- elseif (!module_exists($name)) {
- $actions['enable'][] = $name;
- }
- }
- elseif (module_exists($name)) {
- $actions['disable'][] = $name;
- }
- }
-
- // Gets list of modules prior to install process, unsets $form_state['storage']
- // so we don't get redirected back to the confirmation form.
- $pre_install_list = Drupal::moduleHandler()->getModuleList();
- unset($form_state['storage']);
-
- // Reverse the 'enable' list, to order dependencies before dependents.
- krsort($actions['enable']);
-
- // Installs, enables, and disables modules.
- module_enable($actions['enable'], FALSE);
- module_disable($actions['disable'], FALSE);
-
- // Gets module list after install process, flushes caches and displays a
- // message if there are changes.
- $post_install_list = Drupal::moduleHandler()->getModuleList();
- if ($pre_install_list != $post_install_list) {
- drupal_flush_all_caches();
- drupal_set_message(t('The configuration options have been saved.'));
- }
-
- $form_state['redirect'] = 'admin/modules';
-}
-
-/**
* Uninstall functions
*/
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index ae4131d..f03ae44 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -731,23 +731,22 @@ function system_menu() {
$items['admin/modules'] = array(
'title' => 'Extend',
'description' => 'Add and enable modules to extend site functionality.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('system_modules'),
- 'access arguments' => array('administer modules'),
- 'file' => 'system.admin.inc',
+ 'route_name' => 'system_modules_list',
'weight' => -2,
);
$items['admin/modules/list'] = array(
'title' => 'List',
+ 'access arguments' => array('administer modules'),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/modules/list/confirm'] = array(
'title' => 'List',
- 'access arguments' => array('administer modules'),
+ 'route_name' => 'system_modules_list_confirm',
'type' => MENU_VISIBLE_IN_BREADCRUMB,
);
$items['admin/modules/uninstall'] = array(
'title' => 'Uninstall',
+ 'page callback' => 'drupal_get_form',
'page arguments' => array('system_modules_uninstall'),
'access arguments' => array('administer modules'),
'type' => MENU_LOCAL_TASK,
diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml
index 45ce1e5..f90f5d0 100644
--- a/core/modules/system/system.routing.yml
+++ b/core/modules/system/system.routing.yml
@@ -95,6 +95,20 @@ system_run_cron:
requirements:
_permission: 'administer site configuration'
+system_modules_list:
+ pattern: 'admin/modules'
+ defaults:
+ _form: 'Drupal\system\Form\ModulesListForm'
+ requirements:
+ _permission: 'administer modules'
+
+system_modules_list_confirm:
+ pattern: 'admin/modules/list/confirm'
+ defaults:
+ _form: 'Drupal\system\Form\ModulesListForm'
+ requirements:
+ _permission: 'administer modules'
+
date_format_delete:
pattern: 'admin/config/regional/date-time/formats/{format_id}/delete'
defaults: