diff -u b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php --- b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php @@ -11,6 +11,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; +use Drupal\Core\Session\AccountInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Access\AccessManager; @@ -25,6 +26,13 @@ class ModulesListForm extends FormBase { /** + * The current user. + * + * @var \Drupal\Core\Session\AccountInterface + */ + protected $currentUser; + + /** * The module handler service. * * @var \Drupal\Core\Extension\ModuleHandlerInterface @@ -45,7 +53,8 @@ return new static( $container->get('module_handler'), $container->get('keyvalue.expirable')->get('module_list'), - $container->get('access_manager') + $container->get('access_manager'), + $container->get('current_user') ); } @@ -59,10 +68,11 @@ * @param \Drupal\Core\Access\AccessManager $access_manager * Access manager. */ - public function __construct(ModuleHandlerInterface $module_handler, KeyValueStoreExpirableInterface $key_value_expirable, AccessManager $access_manager) { + public function __construct(ModuleHandlerInterface $module_handler, KeyValueStoreExpirableInterface $key_value_expirable, AccessManager $access_manager, AccountInterface $current_user) { $this->moduleHandler = $module_handler; $this->keyValueExpirable = $key_value_expirable; $this->accessManager = $access_manager; + $this->currentUser = $current_user; } /** @@ -199,7 +209,7 @@ $row['links']['configure'] = array(); if ($module->status && isset($module->info['configure'])) { $route_parameters = isset($module->info['configure_parameters']) ? $module->info['configure_parameters'] : array(); - if ($this->accessManager->checkNamedRoute($module->info['configure'], $route_parameters, \Drupal::currentUser())) { + if ($this->accessManager->checkNamedRoute($module->info['configure'], $route_parameters, $this->currentUser)) { $item = menu_get_item(trim($this->url($module->info['configure'], $route_parameters), '/')); $row['links']['configure'] = array( '#type' => 'link', reverted: --- b/core/modules/system/lib/Drupal/system/Tests/Form/ModuleListFormWebTest.php +++ /dev/null @@ -1,44 +0,0 @@ - 'Tests \Drupal\system\Form\ModulesListForm.', - 'name' => '\Drupal\system\Form\ModulesListForm web test', - 'group' => 'Module', - ); - } - - /** - * Tests the module list form. - */ - public function testModuleListForm() { - $this->drupalLogin($this->drupalCreateUser(array('administer modules'))); - $this->drupalGet('admin/modules'); - $this->assertResponse('200'); - - // Check that system_test's configure link was rendered correctly. - $this->assertLinkByHref('configure/bar'); - } -} only in patch2: unchanged: --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Form/ModulesListFormWebTest.php @@ -0,0 +1,44 @@ + 'Tests \Drupal\system\Form\ModulesListForm.', + 'name' => '\Drupal\system\Form\ModulesListForm web test', + 'group' => 'Module', + ); + } + + /** + * Tests the module list form. + */ + public function testModuleListForm() { + $this->drupalLogin($this->drupalCreateUser(array('administer modules'))); + $this->drupalGet('admin/modules'); + $this->assertResponse('200'); + + // Check that system_test's configure link was rendered correctly. + $this->assertLinkByHref('configure/bar'); + } +}