You are here

class ThunderTaxonomyPermissions in Thunder 8.5

Same name and namespace in other branches
  1. 8.2 modules/thunder_taxonomy/src/ThunderTaxonomyPermissions.php \Drupal\thunder_taxonomy\ThunderTaxonomyPermissions
  2. 8.3 modules/thunder_taxonomy/src/ThunderTaxonomyPermissions.php \Drupal\thunder_taxonomy\ThunderTaxonomyPermissions
  3. 8.4 modules/thunder_taxonomy/src/ThunderTaxonomyPermissions.php \Drupal\thunder_taxonomy\ThunderTaxonomyPermissions
  4. 6.2.x modules/thunder_taxonomy/src/ThunderTaxonomyPermissions.php \Drupal\thunder_taxonomy\ThunderTaxonomyPermissions
  5. 6.0.x modules/thunder_taxonomy/src/ThunderTaxonomyPermissions.php \Drupal\thunder_taxonomy\ThunderTaxonomyPermissions
  6. 6.1.x modules/thunder_taxonomy/src/ThunderTaxonomyPermissions.php \Drupal\thunder_taxonomy\ThunderTaxonomyPermissions

Provides dynamic permissions of the taxonomy module.

Hierarchy

Expanded class hierarchy of ThunderTaxonomyPermissions

See also

thunder_taxonomy_access.permissions.yml

File

modules/thunder_taxonomy/src/ThunderTaxonomyPermissions.php, line 15

Namespace

Drupal\thunder_taxonomy
View source
class ThunderTaxonomyPermissions implements ContainerInjectionInterface {
  use StringTranslationTrait;

  /**
   * The entity manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a TaxonomyPermissions instance.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entityTypeManager) {
    $this->entityTypeManager = $entityTypeManager;
  }

  /**
   * {@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() {
    $permissions = [];
    foreach ($this->entityTypeManager
      ->getStorage('taxonomy_vocabulary')
      ->loadMultiple() as $vocabulary) {
      $permissions += [
        'view published terms in ' . $vocabulary
          ->id() => [
          'title' => $this
            ->t('View published terms in %vocabulary', [
            '%vocabulary' => $vocabulary
              ->label(),
          ]),
        ],
        'view unpublished terms in ' . $vocabulary
          ->id() => [
          'title' => $this
            ->t('View unpublished terms in %vocabulary', [
            '%vocabulary' => $vocabulary
              ->label(),
          ]),
        ],
      ];
    }
    return $permissions;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
ThunderTaxonomyPermissions::$entityTypeManager protected property The entity manager.
ThunderTaxonomyPermissions::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
ThunderTaxonomyPermissions::permissions public function Get taxonomy permissions.
ThunderTaxonomyPermissions::__construct public function Constructs a TaxonomyPermissions instance.