Skip to content
Snippets Groups Projects

Issue #3357099: Display a link to the user management on the Cloud dashboard if user have a permission

Merged Issue #3357099: Display a link to the user management on the Cloud dashboard if user have a permission
All threads resolved!
Merged Tomotaka Hosomi requested to merge issue/cloud-3357099:3357099-display-a-link into 6.x
All threads resolved!
Files
2
@@ -4,6 +4,7 @@ namespace Drupal\cloud\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -24,15 +25,24 @@ class CloudMenuLinks extends DeriverBase implements ContainerDeriverInterface {
*/
protected $entityTypeManager;
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* Constructs new CloudLocalTasks.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
*/
public function __construct(
EntityTypeManagerInterface $entity_type_manager) {
public function __construct(EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler) {
$this->entityTypeManager = $entity_type_manager;
$this->moduleHandler = $module_handler;
}
/**
@@ -40,7 +50,8 @@ class CloudMenuLinks extends DeriverBase implements ContainerDeriverInterface {
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static(
$container->get('entity_type.manager')
$container->get('entity_type.manager'),
$container->get('module_handler')
);
}
@@ -106,6 +117,19 @@ class CloudMenuLinks extends DeriverBase implements ContainerDeriverInterface {
$links[$id]['parent'] = 'cloud.menu.cloud_links:cloud.service_providers.menu.all';
$links[$id]['weight'] = -120;
}
// Add users link under manage menu if the "RoleAssign" module is enabled.
if ($this->moduleHandler->moduleExists('roleassign')) {
$title = "Users";
$id = "cloud.admin.menu.users";
$links[$id] = $base_plugin_definition;
$links[$id]['title'] = $this->t('@title', ['@title' => $title]);
$links[$id]['route_name'] = "entity.user.collection";
$links[$id]['menu_name'] = 'cloud.admin.menu.users';
$links[$id]['parent'] = 'cloud.admin.menu';
$links[$id]['weight'] = 20;
}
return $links;
}
Loading