core/core.services.yml | 4 +- core/lib/Drupal/Core/Menu/LocalActionManager.php | 18 +------- core/lib/Drupal/Core/Menu/LocalTaskManager.php | 54 ++++++++---------------- 3 files changed, 22 insertions(+), 54 deletions(-) diff --git a/core/core.services.yml b/core/core.services.yml index 0a8fc91..bf21661 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -501,10 +501,10 @@ services: arguments: ['@menu.link_tree', '@entity.manager', '@string_translation'] plugin.manager.menu.local_action: class: Drupal\Core\Menu\LocalActionManager - arguments: ['@controller_resolver', '@request_stack', '@current_route_match', '@router.route_provider', '@module_handler', '@cache.discovery', '@language_manager', '@access_manager', '@current_user', '@renderer'] + arguments: ['@controller_resolver', '@request_stack', '@current_route_match', '@router.route_provider', '@module_handler', '@cache.discovery', '@language_manager', '@access_manager', '@current_user'] plugin.manager.menu.local_task: class: Drupal\Core\Menu\LocalTaskManager - arguments: ['@controller_resolver', '@request_stack', '@current_route_match', '@router.route_provider', '@module_handler', '@cache.discovery', '@language_manager', '@access_manager', '@current_user', '@renderer'] + arguments: ['@controller_resolver', '@request_stack', '@current_route_match', '@router.route_provider', '@module_handler', '@cache.discovery', '@language_manager', '@access_manager', '@current_user'] plugin.manager.menu.contextual_link: class: Drupal\Core\Menu\ContextualLinkManager arguments: ['@controller_resolver', '@module_handler', '@cache.discovery', '@language_manager', '@access_manager', '@current_user', '@request_stack'] diff --git a/core/lib/Drupal/Core/Menu/LocalActionManager.php b/core/lib/Drupal/Core/Menu/LocalActionManager.php index c7182bd..bdee9f3 100644 --- a/core/lib/Drupal/Core/Menu/LocalActionManager.php +++ b/core/lib/Drupal/Core/Menu/LocalActionManager.php @@ -15,7 +15,6 @@ use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator; use Drupal\Core\Plugin\Discovery\YamlDiscovery; use Drupal\Core\Plugin\Factory\ContainerFactory; -use Drupal\Core\Render\RendererInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\Url; @@ -102,13 +101,6 @@ class LocalActionManager extends DefaultPluginManager implements LocalActionMana protected $instances = array(); /** - * The renderer. - * - * @var \Drupal\Core\Render\RendererInterface - */ - protected $renderer; - - /** * Constructs a LocalActionManager object. * * @param \Symfony\Component\HttpKernel\Controller\ControllerResolverInterface $controller_resolver @@ -129,10 +121,8 @@ class LocalActionManager extends DefaultPluginManager implements LocalActionMana * The access manager. * @param \Drupal\Core\Session\AccountInterface $account * The current user. - * @param \Drupal\Core\Render\RendererInterface $renderer - * The renderer. */ - public function __construct(ControllerResolverInterface $controller_resolver, RequestStack $request_stack, RouteMatchInterface $route_match, RouteProviderInterface $route_provider, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, AccessManagerInterface $access_manager, AccountInterface $account, RendererInterface $renderer) { + public function __construct(ControllerResolverInterface $controller_resolver, RequestStack $request_stack, RouteMatchInterface $route_match, RouteProviderInterface $route_provider, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, AccessManagerInterface $access_manager, AccountInterface $account) { // Skip calling the parent constructor, since that assumes annotation-based // discovery. $this->factory = new ContainerFactory($this, 'Drupal\Core\Menu\LocalActionInterface'); @@ -143,7 +133,6 @@ public function __construct(ControllerResolverInterface $controller_resolver, Re $this->accessManager = $access_manager; $this->moduleHandler = $module_handler; $this->account = $account; - $this->renderer = $renderer; $this->alterInfo('menu_local_actions'); $this->setCacheBackend($cache_backend, 'local_action_plugins:' . $language_manager->getCurrentLanguage()->getId(), array('local_action')); } @@ -194,7 +183,6 @@ public function getActionsForRoute($route_appears) { foreach ($this->instances[$route_appears] as $plugin_id => $plugin) { $route_name = $plugin->getRouteName(); $route_parameters = $plugin->getRouteParameters($this->routeMatch); - $access = $this->accessManager->checkNamedRoute($route_name, $route_parameters, $this->account, TRUE); $links[$plugin_id] = array( '#theme' => 'menu_local_action', '#link' => array( @@ -202,11 +190,9 @@ public function getActionsForRoute($route_appears) { 'url' => Url::fromRoute($route_name, $route_parameters), 'localized_options' => $plugin->getOptions($this->routeMatch), ), - '#access' => $access->isAllowed(), + '#access' => $this->accessManager->checkNamedRoute($route_name, $route_parameters, $this->account, TRUE), '#weight' => $plugin->getWeight(), ); - // @todo Remove this after https://www.drupal.org/node/2487600 has landed. - $this->renderer->addCacheableDependency($links, $access); } return $links; diff --git a/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php index a0f1969..826e549 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskManager.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php @@ -20,7 +20,6 @@ use Drupal\Core\Plugin\Factory\ContainerFactory; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteProviderInterface; -use Drupal\Core\Render\RendererInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; use Symfony\Component\HttpFoundation\RequestStack; @@ -104,13 +103,6 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI protected $account; /** - * The renderer. - * - * @var \Drupal\Core\Render\RendererInterface - */ - protected $renderer; - - /** * Constructs a \Drupal\Core\Menu\LocalTaskManager object. * * @param \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver @@ -131,10 +123,8 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI * The access manager. * @param \Drupal\Core\Session\AccountInterface $account * The current user. - * @param \Drupal\Core\Render\RendererInterface $renderer - * The renderer. */ - public function __construct(ControllerResolverInterface $controller_resolver, RequestStack $request_stack, RouteMatchInterface $route_match, RouteProviderInterface $route_provider, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache, LanguageManagerInterface $language_manager, AccessManagerInterface $access_manager, AccountInterface $account, RendererInterface $renderer) { + public function __construct(ControllerResolverInterface $controller_resolver, RequestStack $request_stack, RouteMatchInterface $route_match, RouteProviderInterface $route_provider, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache, LanguageManagerInterface $language_manager, AccessManagerInterface $access_manager, AccountInterface $account) { $this->factory = new ContainerFactory($this, '\Drupal\Core\Menu\LocalTaskInterface'); $this->controllerResolver = $controller_resolver; $this->requestStack = $request_stack; @@ -143,7 +133,6 @@ public function __construct(ControllerResolverInterface $controller_resolver, Re $this->accessManager = $access_manager; $this->account = $account; $this->moduleHandler = $module_handler; - $this->renderer = $renderer; $this->alterInfo('local_tasks'); $this->setCacheBackend($cache, 'local_task_plugins:' . $language_manager->getCurrentLanguage()->getId(), array('local_task')); } @@ -312,32 +301,25 @@ public function getTasksBuild($current_route_name) { $route_name = $child->getRouteName(); $route_parameters = $child->getRouteParameters($this->routeMatch); - // Find out whether the user has access to the task. - $access = $this->accessManager->checkNamedRoute($route_name, $route_parameters, $this->account, TRUE); - if ($access->isAllowed()) { - $active = $this->isRouteActive($current_route_name, $route_name, $route_parameters); + $active = $this->isRouteActive($current_route_name, $route_name, $route_parameters); - // The plugin may have been set active in getLocalTasksForRoute() if - // one of its child tabs is the active tab. - $active = $active || $child->getActive(); - // @todo It might make sense to use link render elements instead. + // The plugin may have been set active in getLocalTasksForRoute() if + // one of its child tabs is the active tab. + $active = $active || $child->getActive(); + // @todo It might make sense to use link render elements instead. - $link = array( - 'title' => $this->getTitle($child), - 'url' => Url::fromRoute($route_name, $route_parameters), - 'localized_options' => $child->getOptions($this->routeMatch), - ); - $build[$level][$plugin_id] = array( - '#theme' => 'menu_local_task', - '#link' => $link, - '#active' => $active, - '#weight' => $child->getWeight(), - '#access' => $access->isAllowed(), - ); - // @todo Remove this after https://www.drupal.org/node/2487600 has - // landed. - $this->renderer->addCacheableDependency($build, $access); - } + $link = array( + 'title' => $this->getTitle($child), + 'url' => Url::fromRoute($route_name, $route_parameters), + 'localized_options' => $child->getOptions($this->routeMatch), + ); + $build[$level][$plugin_id] = array( + '#theme' => 'menu_local_task', + '#link' => $link, + '#active' => $active, + '#weight' => $child->getWeight(), + '#access' => $access = $this->accessManager->checkNamedRoute($route_name, $route_parameters, $this->account, TRUE), + ); } }