Loading admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php +23 −2 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Component\Plugin\Derivative\DeriverBase; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Drupal\Core\Session\AccountInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** Loading Loading @@ -55,15 +56,23 @@ class ExtraLinks extends DeriverBase implements ContainerDeriverInterface { */ protected $config; /** * The current user. * * @var \Drupal\Core\Session\AccountInterface */ protected $currentUser; /** * {@inheritdoc} */ public function __construct(EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, ThemeHandlerInterface $theme_handler, ConfigFactoryInterface $config_factory) { public function __construct(EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, ThemeHandlerInterface $theme_handler, ConfigFactoryInterface $config_factory, AccountInterface $current_user) { $this->entityTypeManager = $entity_type_manager; $this->moduleHandler = $module_handler; $this->routeProvider = $route_provider; $this->themeHandler = $theme_handler; $this->config = $config_factory->get('admin_toolbar_tools.settings'); $this->currentUser = $current_user; } /** Loading @@ -75,7 +84,8 @@ class ExtraLinks extends DeriverBase implements ContainerDeriverInterface { $container->get('module_handler'), $container->get('router.route_provider'), $container->get('theme_handler'), $container->get('config.factory') $container->get('config.factory'), $container->get('current_user') ); } Loading Loading @@ -180,6 +190,17 @@ class ExtraLinks extends DeriverBase implements ContainerDeriverInterface { 'weight' => 3, ] + $base_plugin_definition; } if ($this->routeExists('entity.' . $bundle->getEntityTypeId() . '.entity_permissions_form')) { $links['entity.entity_permissions_form.' . $content_entity . '.default.' . $machine_name] = [ 'title' => $this->t('Manage permissions'), 'route_name' => 'entity.' . $bundle->getEntityTypeId() . '.entity_permissions_form', 'parent' => $base_plugin_definition['id'] . ':' . $content_entity_bundle_root, 'route_parameters' => [ $bundle->getEntityTypeId() => $machine_name, ], 'weight' => 3, ] + $base_plugin_definition; } } if ($this->moduleHandler->moduleExists('devel') && $this->routeExists('entity.' . $content_entity_bundle . '.devel_load')) { $links['entity.' . $content_entity_bundle . '.devel_load.' . $machine_name] = [ Loading Loading
admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php +23 −2 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Component\Plugin\Derivative\DeriverBase; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Drupal\Core\Session\AccountInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** Loading Loading @@ -55,15 +56,23 @@ class ExtraLinks extends DeriverBase implements ContainerDeriverInterface { */ protected $config; /** * The current user. * * @var \Drupal\Core\Session\AccountInterface */ protected $currentUser; /** * {@inheritdoc} */ public function __construct(EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, ThemeHandlerInterface $theme_handler, ConfigFactoryInterface $config_factory) { public function __construct(EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, ThemeHandlerInterface $theme_handler, ConfigFactoryInterface $config_factory, AccountInterface $current_user) { $this->entityTypeManager = $entity_type_manager; $this->moduleHandler = $module_handler; $this->routeProvider = $route_provider; $this->themeHandler = $theme_handler; $this->config = $config_factory->get('admin_toolbar_tools.settings'); $this->currentUser = $current_user; } /** Loading @@ -75,7 +84,8 @@ class ExtraLinks extends DeriverBase implements ContainerDeriverInterface { $container->get('module_handler'), $container->get('router.route_provider'), $container->get('theme_handler'), $container->get('config.factory') $container->get('config.factory'), $container->get('current_user') ); } Loading Loading @@ -180,6 +190,17 @@ class ExtraLinks extends DeriverBase implements ContainerDeriverInterface { 'weight' => 3, ] + $base_plugin_definition; } if ($this->routeExists('entity.' . $bundle->getEntityTypeId() . '.entity_permissions_form')) { $links['entity.entity_permissions_form.' . $content_entity . '.default.' . $machine_name] = [ 'title' => $this->t('Manage permissions'), 'route_name' => 'entity.' . $bundle->getEntityTypeId() . '.entity_permissions_form', 'parent' => $base_plugin_definition['id'] . ':' . $content_entity_bundle_root, 'route_parameters' => [ $bundle->getEntityTypeId() => $machine_name, ], 'weight' => 3, ] + $base_plugin_definition; } } if ($this->moduleHandler->moduleExists('devel') && $this->routeExists('entity.' . $content_entity_bundle . '.devel_load')) { $links['entity.' . $content_entity_bundle . '.devel_load.' . $machine_name] = [ Loading