class TcaPermissionGenerator in Token Content Access 8
Same name and namespace in other branches
- 2.0.x src/TcaPermissionGenerator.php \Drupal\tca\TcaPermissionGenerator
Class TcaPermissionGenerator.
@package Drupal\tca
Hierarchy
- class \Drupal\tca\TcaPermissionGenerator implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of TcaPermissionGenerator
File
- src/
TcaPermissionGenerator.php, line 17
Namespace
Drupal\tcaView source
class TcaPermissionGenerator implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* Drupal\Core\Entity\EntityTypeManager definition.
*
* @var Drupal\Core\Entity\EntityTypeManager
*/
private $entityTypeManager = NULL;
/**
* Drupal\tca\Plugin\TcaPluginManager definition.
*
* @var Drupal\tca\Plugin\TcaPluginManager
*/
private $tcaPluginManager = NULL;
/**
* Constructor.
*/
public function __construct(EntityTypeManagerInterface $etm, TcaPluginManager $tca_plugin_manager, TranslationInterface $translation) {
$this->entityTypeManager = $etm;
$this->tcaPluginManager = $tca_plugin_manager;
$this->stringTranslation = $translation;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'), $container
->get('plugin.manager.tca_plugin'), $container
->get('string_translation'));
}
/**
* Return an array of per-entity tca permissions.
*
* @return array
* An array of permissions
*/
public function permissions() {
$permissions = [];
foreach ($this->tcaPluginManager
->getDefinitions() as $def) {
$entity_type = $this->entityTypeManager
->getStorage($def['entityType'])
->getEntityType();
$permissions += [
'tca administer ' . $def['entityType'] => [
'title' => $this
->t('Administer Token Content Access settings for %entity_type', [
'%entity_type' => $entity_type
->getLabel(),
]),
],
'tca bypass ' . $def['entityType'] => [
'title' => $this
->t('Bypass Token Content Access action for %entity_type', [
'%entity_type' => $entity_type
->getLabel(),
]),
],
];
}
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. | |
TcaPermissionGenerator:: |
private | property | Drupal\Core\Entity\EntityTypeManager definition. | |
TcaPermissionGenerator:: |
private | property | Drupal\tca\Plugin\TcaPluginManager definition. | |
TcaPermissionGenerator:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
TcaPermissionGenerator:: |
public | function | Return an array of per-entity tca permissions. | |
TcaPermissionGenerator:: |
public | function | Constructor. |