entityTypeManager = $entity_type_manager; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static($container->get('entity_type.manager')); } /** * Get taxonomy permissions. * * @return array * Permissions array. */ public function permissions() { return $this->generatePermissions(Vocabulary::loadMultiple(), [$this, 'buildPermissions']); } /** * Builds a standard list of taxonomy term permissions for a given vocabulary. * * @param \Drupal\taxonomy\VocabularyInterface $vocabulary * The vocabulary. * * @return array * An array of permission names and descriptions. */ 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.'), ], ]; } }