diff --git a/core/modules/taxonomy/src/Tests/VocabularyPermissionsTest.php b/core/modules/taxonomy/src/Tests/VocabularyPermissionsTest.php index 0c5f2ad..1a94988 100644 --- a/core/modules/taxonomy/src/Tests/VocabularyPermissionsTest.php +++ b/core/modules/taxonomy/src/Tests/VocabularyPermissionsTest.php @@ -24,7 +24,8 @@ protected function setUp() { * Create, edit and delete a vocabulary via the user interface. */ function testVocabularyPermissionsVocabulary() { - // VocabularyTest.php already tests for user with "administer taxonomy". + // VocabularyTest.php already tests for user with "administer taxonomy" + // permission. // Test as user without proper permissions. $authenticated_user = $this->drupalCreateUser([]); diff --git a/core/modules/taxonomy/src/VocabularyListBuilder.php b/core/modules/taxonomy/src/VocabularyListBuilder.php index 4988e94..b73445b 100644 --- a/core/modules/taxonomy/src/VocabularyListBuilder.php +++ b/core/modules/taxonomy/src/VocabularyListBuilder.php @@ -15,6 +15,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; +use Drupal\taxonomy\Access\TaxonomyOverviewAccessCheck; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -54,12 +55,15 @@ class VocabularyListBuilder extends DraggableListBuilder { * The current user. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager service. + * @param \Drupal\taxonomy\Access\TaxonomyOverviewAccessCheck $access_view + * The access check service. */ - public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, AccountInterface $current_user, EntityManagerInterface $entity_manager) { + public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, AccountInterface $current_user, EntityManagerInterface $entity_manager, TaxonomyOverviewAccessCheck $access_view) { parent::__construct($entity_type, $storage); $this->current_user = $current_user; $this->entityManager = $entity_manager; + $this->access_view = $access_view; } /** @@ -70,7 +74,8 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $entity_type, $container->get('entity.manager')->getStorage($entity_type->id()), $container->get('current_user'), - $container->get('entity.manager') + $container->get('entity.manager'), + $container->get('access_check.taxonomy.taxonomy_overview') ); } @@ -91,11 +96,14 @@ public function getDefaultOperations(EntityInterface $entity) { $operations['edit']['title'] = t('Edit vocabulary'); } - $operations['list'] = array( - 'title' => t('List terms'), - 'weight' => 0, - 'url' => $entity->urlInfo('overview-form'), - ); + if($this->access_view->access($this->current_user)) { + $operations['list'] = array( + 'title' => t('List terms'), + 'weight' => 0, + 'url' => $entity->urlInfo('overview-form'), + ); + } + $taxonomy_term_access_control_handler = $this->entityManager->getAccessControlHandler('taxonomy_term'); if ($taxonomy_term_access_control_handler->createAccess($entity->id())) { $operations['add'] = [ @@ -126,12 +134,9 @@ public function buildHeader() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $taxonomy_term_access_control_handler = $this->entityManager->getAccessControlHandler('taxonomy_term'); - if ($taxonomy_term_access_control_handler->createAccess($entity->id())) { $row['label'] = $entity->label(); return $row + parent::buildRow($entity); } - } /** * {@inheritdoc}