commit 415fbd3328a7de1b6c7fe50388034ad744d2f097 Author: Pancho Date: Mon May 20 11:17:54 2013 +0200 1990544-17 diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php index 3eb06d8..2ce8a28 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php @@ -7,22 +7,38 @@ namespace Drupal\system\Form; +use Drupal\Component\Utility\String; +use Drupal\Component\Utility\Unicode; +use Drupal\Core\ControllerInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -class ModulesListForm implements FormInterface { - +class ModulesListForm implements FormInterface, ControllerInterface { /** - * {@inheritdoc} + * The module handler service. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface */ - public static function create(ContainerInterface $container) { - return new static(); + protected $moduleHandler; + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('module_handler') + ); } - /** - * {@inheritdoc} + /** + * Constructs a ModulesListForm object. + * + * @param ModuleHandlerInterface $module_handler + * A module handler. */ - public function __construct() { + public function __construct(ModuleHandlerInterface $module_handler) { + $this->moduleHandler = $module_handler; } /** @@ -65,7 +81,7 @@ class ModulesListForm implements FormInterface { } } - \Drupal::moduleHandler()->loadInclude('system', 'inc', 'system.admin'); + $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 @@ -107,7 +123,7 @@ class ModulesListForm implements FormInterface { // 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()); + $distribution_name = String::checkPlain(drupal_install_profile_distribution_name()); // Iterate through each of the modules. foreach ($visible_files as $filename => $module) { @@ -121,7 +137,7 @@ class ModulesListForm implements FormInterface { // 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['requires'][$requires] = t('@module (missing)', array('@module' => Unicode::ucfirst($requires))); $extra['disabled'] = TRUE; } // Only display visible modules. @@ -152,8 +168,8 @@ class ModulesListForm implements FormInterface { } } // 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)) { + 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'), @@ -163,7 +179,7 @@ class ModulesListForm implements FormInterface { } } // 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'))) { + if ($module->status && user_access('administer permissions') && in_array($filename, $this->moduleHandler->getImplementations('permission'))) { $extra['links']['permissions'] = array( '#type' => 'link', '#title' => t('Permissions'), @@ -443,7 +459,7 @@ class ModulesListForm implements FormInterface { // Gets module list after install process, flushes caches and displays a // message if there are changes. - $post_install_list = drupal_container()->get('module_handler')->getModuleList(); + $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.'));