class TaxonomyPermissions in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/taxonomy/src/TaxonomyPermissions.php \Drupal\taxonomy\TaxonomyPermissions
Provides dynamic permissions of the taxonomy module.
Hierarchy
- class \Drupal\taxonomy\TaxonomyPermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of TaxonomyPermissions
See also
File
- core/
modules/ taxonomy/ src/ TaxonomyPermissions.php, line 20 - Contains \Drupal\taxonomy\TaxonomyPermissions.
Namespace
Drupal\taxonomyView source
class TaxonomyPermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* Constructs a TaxonomyPermissions instance.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
*/
public function __construct(EntityManagerInterface $entity_manager) {
$this->entityManager = $entity_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity.manager'));
}
/**
* Get taxonomy permissions.
*
* @return array
* Permissions array.
*/
public function permissions() {
$permissions = [];
foreach ($this->entityManager
->getStorage('taxonomy_vocabulary')
->loadMultiple() as $vocabulary) {
$permissions += [
'edit terms in ' . $vocabulary
->id() => [
'title' => $this
->t('Edit terms in %vocabulary', [
'%vocabulary' => $vocabulary
->label(),
]),
],
];
$permissions += [
'delete terms in ' . $vocabulary
->id() => [
'title' => $this
->t('Delete terms from %vocabulary', [
'%vocabulary' => $vocabulary
->label(),
]),
],
];
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
StringTranslationTrait:: |
protected | property | The string translation service. | |
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 manager. | |
TaxonomyPermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
TaxonomyPermissions:: |
public | function | Get taxonomy permissions. | |
TaxonomyPermissions:: |
public | function | Constructs a TaxonomyPermissions instance. |