class TaxonomyPermissions in Taxonomy Permissions 8
Defines a class for dynamic permissions based on vocabularies.
Hierarchy
- class \Drupal\taxonomy_permissions\TaxonomyPermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of TaxonomyPermissions
File
- src/
TaxonomyPermissions.php, line 14
Namespace
Drupal\taxonomy_permissionsView source
class TaxonomyPermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'));
}
/**
* Returns an array of transition permissions.
*
* @return array
* The access protected permissions.
*/
public function permissions() {
$perms = [];
$vocabularies = Vocabulary::loadMultiple();
/* @var \Drupal\taxonomy\Entity\Vocabulary $vocabulary */
foreach ($vocabularies as $id => $vocabulary) {
$perms['view terms in ' . $id] = [
'title' => $this
->t('View terms in %label', [
'%label' => $vocabulary
->label(),
]),
'description' => $this
->t('View the terms of %label vocabulary', [
'%label' => $vocabulary
->label(),
]),
];
}
return $perms;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
TaxonomyPermissions:: |
protected | property | The entity type manager. | |
TaxonomyPermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
TaxonomyPermissions:: |
public | function | Returns an array of transition permissions. | |
TaxonomyPermissions:: |
public | function | Constructor. |