You are here

class NodeAuthlinkPermissions in Node authorize link 8

Node authlink permissions generator.

Hierarchy

Expanded class hierarchy of NodeAuthlinkPermissions

File

src/NodeAuthlinkPermissions.php, line 13

Namespace

Drupal\node_authlink
View source
class NodeAuthlinkPermissions implements ContainerInjectionInterface {
  use StringTranslationTrait;

  /**
   * Used to get all the node types.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * NodeAuthlinkPermissions constructor.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   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'));
  }

  /**
   * Permissions callback to granularize node authlink.
   */
  public function permissions() {
    $permissions = [];
    foreach ($this->entityTypeManager
      ->getStorage('node_type')
      ->loadMultiple() as $nodeType) {
      $permission_name = sprintf('create and delete node %s authlinks', $nodeType
        ->id());
      $permissions[$permission_name] = [
        'title' => $this
          ->t('Create and delete node "@node_type" authlinks', [
          '@node_type' => $nodeType
            ->label(),
        ]),
      ];
    }
    return $permissions;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
NodeAuthlinkPermissions::$entityTypeManager protected property Used to get all the node types.
NodeAuthlinkPermissions::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
NodeAuthlinkPermissions::permissions public function Permissions callback to granularize node authlink.
NodeAuthlinkPermissions::__construct public function NodeAuthlinkPermissions constructor.
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.