diff --git a/src/TaxonomyPermissions.php b/src/TaxonomyPermissions.php index 7577bff..77ff36f 100644 --- a/src/TaxonomyPermissions.php +++ b/src/TaxonomyPermissions.php @@ -5,6 +5,7 @@ namespace Drupal\taxonomy_permissions; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\core\Entity\EntityTypeManagerInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Drupal\taxonomy\Entity\Vocabulary; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -47,7 +48,7 @@ class TaxonomyPermissions implements ContainerInjectionInterface { public function permissions() { $perms = []; - $vocabularies = $this->entityTypeManager->getStorage('taxonomy_vocabulary')->loadMultiple(); + $vocabularies = Vocabulary::loadMultiple(); /* @var \Drupal\taxonomy\Entity\Vocabulary $vocabulary */ foreach ($vocabularies as $id => $vocabulary) { $perms['view terms in ' . $id] = [ diff --git a/src/TaxonomyPermissionsControlHandler.php b/src/TaxonomyPermissionsControlHandler.php index 7ee27d4..06f87f0 100644 --- a/src/TaxonomyPermissionsControlHandler.php +++ b/src/TaxonomyPermissionsControlHandler.php @@ -23,6 +23,10 @@ class TaxonomyPermissionsControlHandler extends EntityAccessControlHandler { return AccessResult::allowedIfHasPermissions($account, ["view terms in {$entity->bundle()}", 'administer taxonomy'], 'OR'); break; + case 'create': + return AccessResult::allowedIfHasPermissions($account, ["create terms in {$entity->bundle()}", 'administer taxonomy'], 'OR'); + break; + case 'update': return AccessResult::allowedIfHasPermissions($account, ["edit terms in {$entity->bundle()}", 'administer taxonomy'], 'OR'); break; diff --git a/taxonomy_permissions.install b/taxonomy_permissions.install index 3dd5eff..ce31a4a 100644 --- a/taxonomy_permissions.install +++ b/taxonomy_permissions.install @@ -5,7 +5,8 @@ * Install, update and uninstall functions for the taxonomy_permissions module. */ -use \Drupal\Core\Session\AccountInterface; +use Drupal\Core\Session\AccountInterface; +use Drupal\taxonomy\Entity\Vocabulary; /** * Implements hook_install(). @@ -15,7 +16,7 @@ use \Drupal\Core\Session\AccountInterface; */ function taxonomy_permissions_install() { $perms = []; - $vocabularies = Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary')->loadMultiple(); + $vocabularies = Vocabulary::loadMultiple(); foreach ($vocabularies as $id => $vocabulary) { $perms[] = 'view terms in ' . $id; } diff --git a/taxonomy_permissions.module b/taxonomy_permissions.module index bb37de8..3b8e142 100644 --- a/taxonomy_permissions.module +++ b/taxonomy_permissions.module @@ -84,9 +84,6 @@ function taxonomy_permissions_entity_insert(EntityInterface $entity) { /** * Implements hook_entity_delete(). */ -/** - * Implements hook_entity_delete(). - */ function taxonomy_permissions_entity_delete(EntityInterface $entity) { if ($entity->getEntityTypeId() == 'taxonomy_vocabulary') { $perms[] = 'view terms in ' . $entity->id();