class NodeAuthlinkPermissions in Node authorize link 8
Node authlink permissions generator.
Hierarchy
- class \Drupal\node_authlink\NodeAuthlinkPermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of NodeAuthlinkPermissions
File
- src/
NodeAuthlinkPermissions.php, line 13
Namespace
Drupal\node_authlinkView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
NodeAuthlinkPermissions:: |
protected | property | Used to get all the node types. | |
NodeAuthlinkPermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
NodeAuthlinkPermissions:: |
public | function | Permissions callback to granularize node authlink. | |
NodeAuthlinkPermissions:: |
public | function | NodeAuthlinkPermissions constructor. | |
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. |