class InvitePermissions in Invite 8
Provides dynamic permissions of the invite module.
Hierarchy
- class \Drupal\invite\InvitePermissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of InvitePermissions
File
- src/
InvitePermissions.php, line 13
Namespace
Drupal\inviteView source
class InvitePermissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManager
*/
protected $entityTypeManager;
/**
* Constructs a new InvitePermissions 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'));
}
/**
* Returns an array of invite permissions.
*
* @return array
* Returns the array with permissions.
*/
public function permissions() {
$permissions = [];
// Generate permissions for each invite type.
$invite_types = $this->entityTypeManager
->getStorage('invite_type')
->loadMultiple();
foreach ($invite_types as $invite_type) {
$permissions['invite_type_' . $invite_type
->getType()] = [
'title' => $this
->t('Create @label invites', [
'@label' => $invite_type
->label(),
]),
'description' => [
'#prefix' => '<em>',
'#markup' => $this
->t('Warning: This permission could have security implications.'),
'#suffix' => '</em>',
],
];
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
InvitePermissions:: |
protected | property | The entity type manager. | |
InvitePermissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
InvitePermissions:: |
public | function | Returns an array of invite permissions. | |
InvitePermissions:: |
public | function | Constructs a new InvitePermissions instance. | |
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. |