reverted:
--- b/core/modules/taxonomy/lib/Drupal/taxonomy/Access/TaxonomyOverviewAccessCheck.php
+++ /dev/null
@@ -1,36 +0,0 @@
-hasPermission('administer taxonomy') || $account->hasPermission('access taxonomy overview');
-
- return $access ? static::ALLOW : static::DENY;
- }
-
-}
diff -u b/core/modules/taxonomy/src/Form/OverviewTerms.php b/core/modules/taxonomy/src/Form/OverviewTerms.php
--- b/core/modules/taxonomy/src/Form/OverviewTerms.php
+++ b/core/modules/taxonomy/src/Form/OverviewTerms.php
@@ -27,6 +27,13 @@
protected $moduleHandler;
/**
+ * The entity manager.
+ *
+ * @var \Drupal\Core\Entity\EntityManagerInterface
+ */
+ protected $entityManager;
+
+ /**
* The term storage controller.
*
* @var \Drupal\taxonomy\TermStorageInterface
@@ -43,6 +50,7 @@
*/
public function __construct(ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager) {
$this->moduleHandler = $module_handler;
+ $this->entityManager = $entity_manager;
$this->storageController = $entity_manager->getStorage('taxonomy_term');
}
@@ -204,8 +212,8 @@
$destination = $this->getDestinationArray();
$row_position = 0;
// Build the actual form.
- $access_controller = \Drupal::entityManager()->getAccessController('taxonomy_term');
- if ($access_controller->createAccess($taxonomy_vocabulary->id())) {
+ $access_control_handler = $this->entityManager->getAccessControlHandler('taxonomy_term');
+ if ($access_control_handler->createAccess($taxonomy_vocabulary->id())) {
$empty = $this->t('No terms available. Add term.', ['@link' => $this->url('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $taxonomy_vocabulary->id()])]);
}
else {
diff -u b/core/modules/taxonomy/src/VocabularyListBuilder.php b/core/modules/taxonomy/src/VocabularyListBuilder.php
--- b/core/modules/taxonomy/src/VocabularyListBuilder.php
+++ b/core/modules/taxonomy/src/VocabularyListBuilder.php
@@ -9,8 +9,13 @@
use Drupal\Core\Config\Entity\DraggableListBuilder;
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Entity\EntityStorageInterface;
+use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Defines a class to build a listing of taxonomy vocabulary entities.
@@ -25,6 +30,51 @@
protected $entitiesKey = 'vocabularies';
/**
+ * The current user.
+ *
+ * @var \Drupal\Core\Session\AccountInterface
+ */
+ protected $currentUser;
+
+ /**
+ * The entity manager.
+ *
+ * @var \Drupal\Core\Entity\EntityManagerInterface
+ */
+ protected $entityManager;
+
+ /**
+ * Constructs a new VocabularyListBuilder object.
+ *
+ * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
+ * The entity type definition.
+ * @param \Drupal\Core\Entity\EntityStorageInterface $storage
+ * The entity storage class.
+ * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
+ * The entity manager service.
+ * @param \Drupal\Core\Session\AccountInterface $current_user
+ * The current user.
+ */
+ public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, AccountInterface $current_user, EntityManagerInterface $entity_manager) {
+ parent::__construct($entity_type, $storage);
+
+ $this->current_user = $current_user;
+ $this->entityManager = $entity_manager;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
+ return new static(
+ $entity_type,
+ $container->get('entity.manager')->getStorage($entity_type->id()),
+ $container->get('current_user'),
+ $container->get('entity.manager')
+ );
+ }
+
+ /**
* {@inheritdoc}
*/
public function getFormId() {
@@ -46,8 +96,8 @@
'weight' => 0,
'url' => $entity->urlInfo('overview-form'),
);
- $access_controller = \Drupal::entityManager()->getAccessController('taxonomy_term');
- if ($access_controller->createAccess($entity->bundle())) {
+ $taxonomy_term_access_control_handler = $this->entityManager->getAccessControlHandler('taxonomy_term');
+ if ($taxonomy_term_access_control_handler->createAccess($entity->bundle())) {
$operations['add'] = array(
'title' => t('Add terms'),
'weight' => 10,
@@ -65,7 +115,7 @@
public function buildHeader() {
$header['label'] = t('Vocabulary name');
- if (user_access('administer vocabularies')) {
+ if ($this->current_user->hasPermission('administer vocabularies')) {
$header['weight'] = t('Weight');
}
@@ -92,7 +142,7 @@
}
$build = parent::render();
- if (user_access('administer vocabularies')) {
+ if ($this->current_user->hasPermission('administer vocabularies')) {
$build['table']['#empty'] = t('No vocabularies available. Add vocabulary.', array('@link' => \Drupal::url('entity.taxonomy_vocabulary.add_form')));
}
else {
diff -u b/core/modules/taxonomy/taxonomy.services.yml b/core/modules/taxonomy/taxonomy.services.yml
--- b/core/modules/taxonomy/taxonomy.services.yml
+++ b/core/modules/taxonomy/taxonomy.services.yml
@@ -10 +10 @@
- - { name: access_check }
+ - { name: access_check, applies_to: _access_taxonomy_overview }
only in patch2:
unchanged:
--- /dev/null
+++ b/core/modules/taxonomy/src/Access/TaxonomyOverviewAccessCheck.php
@@ -0,0 +1,28 @@
+hasPermission('administer taxonomy') || $account->hasPermission('access taxonomy overview');
+ return AccessResult::allowedIf($access);
+ }
+
+}