3 namespace Drupal\taxonomy;
5 use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
6 use Drupal\Core\Entity\EntityManagerInterface;
7 use Drupal\Core\StringTranslation\StringTranslationTrait;
8 use Symfony\Component\DependencyInjection\ContainerInterface;
11 * Provides dynamic permissions of the taxonomy module.
13 * @see taxonomy.permissions.yml
15 class TaxonomyPermissions implements ContainerInjectionInterface {
17 use StringTranslationTrait;
22 * @var \Drupal\Core\Entity\EntityManagerInterface
24 protected $entityManager;
27 * Constructs a TaxonomyPermissions instance.
29 * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
32 public function __construct(EntityManagerInterface $entity_manager) {
33 $this->entityManager = $entity_manager;
39 public static function create(ContainerInterface $container) {
40 return new static($container->get('entity.manager'));
44 * Get taxonomy permissions.
49 public function permissions() {
51 foreach ($this->entityManager->getStorage('taxonomy_vocabulary')->loadMultiple() as $vocabulary) {
53 'edit terms in ' . $vocabulary->id() => [
54 'title' => $this->t('Edit terms in %vocabulary', ['%vocabulary' => $vocabulary->label()]),
58 'delete terms in ' . $vocabulary->id() => [
59 'title' => $this->t('Delete terms from %vocabulary', ['%vocabulary' => $vocabulary->label()]),