class TaxonomyAccessFixPermissions in Taxonomy access fix 8.2
Same name and namespace in other branches
- 8.3 src/TaxonomyAccessFixPermissions.php \Drupal\taxonomy_access_fix\TaxonomyAccessFixPermissions
Provides additional permissions for entities provided by Taxonomy module.
Hierarchy
- class \Drupal\taxonomy_access_fix\TaxonomyAccessFixPermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of TaxonomyAccessFixPermissions
File
- src/
TaxonomyAccessFixPermissions.php, line 13
Namespace
Drupal\taxonomy_access_fixView source
class TaxonomyAccessFixPermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a TaxonomyAccessFixPermissions instance.
*
* @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'));
}
/**
* Gets additional permissions for Taxonomy Vocabulary entities.
*
* @return array
* Permissions array.
*/
public function getPermissions() {
$permissions = [];
$vocabularies = $this->entityTypeManager
->getStorage('taxonomy_vocabulary')
->loadMultiple();
$schema_version = 0;
if (count($vocabularies) > 0) {
$schema_version = (int) drupal_get_installed_schema_version('taxonomy_access_fix');
}
foreach ($vocabularies as $vocabulary) {
$permissions['view terms in ' . $vocabulary
->id()] = [
'title' => $this
->t('View terms in %vocabulary', [
'%vocabulary' => $vocabulary
->label(),
]),
];
// @todo: Remove in 8.x-3.x or later or mark as deprecated once Issue
// 2924785 has been fixed.
if ($schema_version < 8202) {
$permissions['add terms in ' . $vocabulary
->id()] = [
'title' => $this
->t('Add terms in %vocabulary', [
'%vocabulary' => $vocabulary
->label(),
]),
'description' => $this
->t("This permission is <strong>no longer used</strong> and will be removed in a future release. Use the @permission_label permission provided by Drupal Core's %module_label module instead.", [
'%module_label' => $this
->t('Taxonomy'),
'@permission_label' => $this
->t('"%vocabulary: Create terms"', [
'%vocabulary' => $vocabulary
->label(),
]),
]),
];
}
$permissions['reorder terms in ' . $vocabulary
->id()] = [
'title' => $this
->t('Reorder terms in %vocabulary', [
'%vocabulary' => $vocabulary
->label(),
]),
];
}
return $permissions;
}
}
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. | |
TaxonomyAccessFixPermissions:: |
protected | property | The entity type manager. | |
TaxonomyAccessFixPermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
TaxonomyAccessFixPermissions:: |
public | function | Gets additional permissions for Taxonomy Vocabulary entities. | |
TaxonomyAccessFixPermissions:: |
public | function | Constructs a TaxonomyAccessFixPermissions instance. |