From dfc7b5e2805a3dfc4d6b19ce0c776e9fcb0b2d29 Mon Sep 17 00:00:00 2001 From: Kristiaan Van den Eynde Date: Fri, 2 Aug 2019 14:24:13 +0200 Subject: [PATCH] Issue #3062380 by gorkagr, kristiaanvandeneynde: After update to rc3 /admin/group view (groups list) is not found --- modules/gnode/gnode.module | 14 +++++++---- src/Entity/Controller/GroupListBuilder.php | 28 ++++++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/modules/gnode/gnode.module b/modules/gnode/gnode.module index 01c5e9c..275099c 100644 --- a/modules/gnode/gnode.module +++ b/modules/gnode/gnode.module @@ -407,11 +407,15 @@ function gnode_entity_operation($entity) { if ($entity->getEntityTypeId() == 'group' && \Drupal::moduleHandler()->moduleExists('views')) { if ($entity->hasPermission('access group_node overview', \Drupal::currentUser())) { - $operations['nodes'] = [ - 'title' => t('Nodes'), - 'weight' => 20, - 'url' => Url::fromRoute('view.group_nodes.page_1', ['group' => $entity->id()]), - ]; + /** @var \Symfony\Component\Routing\RouterInterface $router */ + $router = \Drupal::service('router.no_access_checks'); + if ($router->getRouteCollection()->get('view.group_nodes.page_1') !== NULL) { + $operations['nodes'] = [ + 'title' => t('Nodes'), + 'weight' => 20, + 'url' => Url::fromRoute('view.group_nodes.page_1', ['group' => $entity->id()]), + ]; + } } } diff --git a/src/Entity/Controller/GroupListBuilder.php b/src/Entity/Controller/GroupListBuilder.php index f64145a..dd278d9 100644 --- a/src/Entity/Controller/GroupListBuilder.php +++ b/src/Entity/Controller/GroupListBuilder.php @@ -11,6 +11,7 @@ use Drupal\Core\Routing\RedirectDestinationInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\Routing\RouterInterface; /** * Provides a list controller for group entities. @@ -40,6 +41,13 @@ class GroupListBuilder extends EntityListBuilder { */ protected $moduleHandler; + /** + * The router. + * + * @var \Symfony\Component\Routing\RouterInterface + */ + protected $router; + /** * Constructs a new GroupListBuilder object. * @@ -53,12 +61,15 @@ class GroupListBuilder extends EntityListBuilder { * The current user. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. + * @param \Symfony\Component\Routing\RouterInterface $router + * The router. */ - public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, RedirectDestinationInterface $redirect_destination, AccountInterface $current_user, ModuleHandlerInterface $module_handler) { + public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, RedirectDestinationInterface $redirect_destination, AccountInterface $current_user, ModuleHandlerInterface $module_handler, RouterInterface $router) { parent::__construct($entity_type, $storage); $this->redirectDestination = $redirect_destination; $this->currentUser = $current_user; $this->moduleHandler = $module_handler; + $this->router = $router; } /** @@ -70,7 +81,8 @@ class GroupListBuilder extends EntityListBuilder { $container->get('entity_type.manager')->getStorage($entity_type->id()), $container->get('redirect.destination'), $container->get('current_user'), - $container->get('module_handler') + $container->get('module_handler'), + $container->get('router.no_access_checks') ); } @@ -150,11 +162,13 @@ class GroupListBuilder extends EntityListBuilder { /** @var \Drupal\group\Entity\GroupInterface $entity */ if ($this->moduleHandler->moduleExists('views') && $entity->hasPermission('administer members', $this->currentUser)) { - $operations['members'] = [ - 'title' => $this->t('Members'), - 'weight' => 15, - 'url' => Url::fromRoute('view.group_members.page_1', ['group' => $entity->id()]), - ]; + if ($this->router->getRouteCollection()->get('view.group_members.page_1') !== NULL) { + $operations['members'] = [ + 'title' => $this->t('Members'), + 'weight' => 15, + 'url' => Url::fromRoute('view.group_members.page_1', ['group' => $entity->id()]), + ]; + } } // Add the current path or destination as a redirect to the operation links. -- 2.17.1