Same filename and directory in other branches
- 8.9.x core/modules/taxonomy/src/TaxonomyPermissions.php
- 9 core/modules/taxonomy/src/TaxonomyPermissions.php
Namespace
Drupal\taxonomy
File
core/modules/taxonomy/src/TaxonomyPermissions.php
View source
<?php
namespace Drupal\taxonomy;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\BundlePermissionHandlerTrait;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\taxonomy\Entity\Vocabulary;
use Symfony\Component\DependencyInjection\ContainerInterface;
class TaxonomyPermissions implements ContainerInjectionInterface {
use BundlePermissionHandlerTrait;
use StringTranslationTrait;
protected $entityTypeManager;
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'));
}
public function permissions() {
return $this
->generatePermissions(Vocabulary::loadMultiple(), [
$this,
'buildPermissions',
]);
}
protected function buildPermissions(VocabularyInterface $vocabulary) {
$id = $vocabulary
->id();
$args = [
'%vocabulary' => $vocabulary
->label(),
];
return [
"create terms in {$id}" => [
'title' => $this
->t('%vocabulary: Create terms', $args),
],
"delete terms in {$id}" => [
'title' => $this
->t('%vocabulary: Delete terms', $args),
],
"edit terms in {$id}" => [
'title' => $this
->t('%vocabulary: Edit terms', $args),
],
"view term revisions in {$id}" => [
'title' => $this
->t('%vocabulary: View term revisions', $args),
],
"revert term revisions in {$id}" => [
'title' => $this
->t('%vocabulary: Revert term revisions', $args),
'description' => $this
->t('To revert a revision you also need permission to edit the taxonomy term.'),
],
"delete term revisions in {$id}" => [
'title' => $this
->t('%vocabulary: Delete term revisions', $args),
'description' => $this
->t('To delete a revision you also need permission to delete the taxonomy term.'),
],
];
}
}
Classes