summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2015-07-02 07:01:47 (GMT)
committerwebchick2015-07-02 07:01:47 (GMT)
commitf96deaa500800288396903bd276aee9dc740bb35 (patch)
tree3902a107545d6b1c2298feace803e3fdf222a60e
parent40335e9773b5a13e89920922f516e9a2d04d9b08 (diff)
Issue #2513626 by cilefen, akalata, Les Lim: [Regression] Module permission links missing from module list page
-rw-r--r--core/modules/system/src/Form/ModulesListForm.php18
-rw-r--r--core/modules/system/src/Tests/Form/ModulesListFormWebTest.php10
-rw-r--r--core/modules/system/tests/modules/system_test/system_test.permissions.yml2
3 files changed, 26 insertions, 4 deletions
diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php
index 173fcc7..73b32ec 100644
--- a/core/modules/system/src/Form/ModulesListForm.php
+++ b/core/modules/system/src/Form/ModulesListForm.php
@@ -24,6 +24,7 @@ use Drupal\Core\Render\Element;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Routing\RouteProviderInterface;
use Drupal\Core\Session\AccountInterface;
+use Drupal\user\PermissionHandlerInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -95,6 +96,13 @@ class ModulesListForm extends FormBase {
protected $moduleInstaller;
/**
+ * The permission handler.
+ *
+ * @var \Drupal\user\PermissionHandlerInterface
+ */
+ protected $permissionHandler;
+
+ /**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
@@ -107,7 +115,8 @@ class ModulesListForm extends FormBase {
$container->get('current_route_match'),
$container->get('title_resolver'),
$container->get('router.route_provider'),
- $container->get('plugin.manager.menu.link')
+ $container->get('plugin.manager.menu.link'),
+ $container->get('user.permissions')
);
}
@@ -132,8 +141,10 @@ class ModulesListForm extends FormBase {
* The route provider.
* @param \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager
* The menu link manager.
+ * @param \Drupal\user\PermissionHandlerInterface $permission_handler
+ * The permission handler.
*/
- public function __construct(ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, KeyValueStoreExpirableInterface $key_value_expirable, AccessManagerInterface $access_manager, AccountInterface $current_user, RouteMatchInterface $route_match, TitleResolverInterface $title_resolver, RouteProviderInterface $route_provider, MenuLinkManagerInterface $menu_link_manager) {
+ public function __construct(ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, KeyValueStoreExpirableInterface $key_value_expirable, AccessManagerInterface $access_manager, AccountInterface $current_user, RouteMatchInterface $route_match, TitleResolverInterface $title_resolver, RouteProviderInterface $route_provider, MenuLinkManagerInterface $menu_link_manager, PermissionHandlerInterface $permission_handler) {
$this->moduleHandler = $module_handler;
$this->moduleInstaller = $module_installer;
$this->keyValueExpirable = $key_value_expirable;
@@ -143,6 +154,7 @@ class ModulesListForm extends FormBase {
$this->titleResolver = $title_resolver;
$this->routeProvider = $route_provider;
$this->menuLinkManager = $menu_link_manager;
+ $this->permissionHandler = $permission_handler;
}
/**
@@ -270,7 +282,7 @@ class ModulesListForm extends FormBase {
// Generate link for module's permission, if the user has access to it.
$row['links']['permissions'] = array();
- if ($module->status && \Drupal::currentUser()->hasPermission('administer permissions') && in_array($module->getName(), $this->moduleHandler->getImplementations('permission'))) {
+ if ($module->status && $this->currentUser->hasPermission('administer permissions') && $this->permissionHandler->moduleProvidesPermissions($module->getName())) {
$row['links']['permissions'] = array(
'#type' => 'link',
'#title' => $this->t('Permissions'),
diff --git a/core/modules/system/src/Tests/Form/ModulesListFormWebTest.php b/core/modules/system/src/Tests/Form/ModulesListFormWebTest.php
index f0945ed..3600364 100644
--- a/core/modules/system/src/Tests/Form/ModulesListFormWebTest.php
+++ b/core/modules/system/src/Tests/Form/ModulesListFormWebTest.php
@@ -33,11 +33,19 @@ class ModulesListFormWebTest extends WebTestBase {
* Tests the module list form.
*/
public function testModuleListForm() {
- $this->drupalLogin($this->drupalCreateUser(array('administer modules')));
+ $this->drupalLogin(
+ $this->drupalCreateUser(
+ array('administer modules', 'administer permissions')
+ )
+ );
$this->drupalGet('admin/modules');
$this->assertResponse('200');
// Check that system_test's configure link was rendered correctly.
$this->assertFieldByXPath("//a[contains(@href, '/system-test/configure/bar') and @title='Bar.bar']");
+
+ // Check that system_test's permissions link was rendered correctly.
+ $this->assertFieldByXPath("//a[contains(@href, '/admin/people/permissions#module-system_test') and @title='Configure permissions']");
}
+
}
diff --git a/core/modules/system/tests/modules/system_test/system_test.permissions.yml b/core/modules/system/tests/modules/system_test/system_test.permissions.yml
new file mode 100644
index 0000000..fd06c57
--- /dev/null
+++ b/core/modules/system/tests/modules/system_test/system_test.permissions.yml
@@ -0,0 +1,2 @@
+system test:
+ title: 'Administer system test' \ No newline at end of file