TaxonomyAccessFixPermissions.php in Taxonomy access fix 8.2
File
src/TaxonomyAccessFixPermissions.php
View source
<?php
namespace Drupal\taxonomy_access_fix;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
class TaxonomyAccessFixPermissions implements ContainerInjectionInterface {
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 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(),
]),
];
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;
}
}