class Permissions in Courier 8
Same name and namespace in other branches
- 2.x courier_message_composer/src/Permissions.php \Drupal\courier_message_composer\Permissions
Define a permission generator for Courier Message Composer.
Hierarchy
- class \Drupal\courier_message_composer\Permissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of Permissions
File
- courier_message_composer/
src/ Permissions.php, line 14
Namespace
Drupal\courier_message_composerView source
class Permissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The identity channel manager.
*
* @var \Drupal\courier\Service\IdentityChannelManager
*/
protected $identityChannelManager;
/**
* Constructs a CourierMessageController object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\courier\Service\IdentityChannelManagerInterface $identity_channel_manager
* The identity channel manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, IdentityChannelManagerInterface $identity_channel_manager) {
$this->entityTypeManager = $entity_type_manager;
$this->identityChannelManager = $identity_channel_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'), $container
->get('plugin.manager.identity_channel'));
}
/**
* Define permissions for each channel + identity combination.
*
* @return array
*/
public function sendMessageToChannels() {
$permissions = [];
$t_args = [];
foreach ($this->identityChannelManager
->getChannels() as $channel => $identity_types) {
$t_args['%channel'] = $this->entityTypeManager
->getDefinition($channel)
->getLabel();
foreach ($identity_types as $identity) {
$t_args['%identity'] = $this->entityTypeManager
->getDefinition($identity)
->getLabel();
$permissions["courier_message_composer compose {$channel} to {$identity}"] = [
'title' => $this
->t('Send %channel to %identity', $t_args),
'description' => $this
->t('Send individual messages to any %identity.', $t_args),
];
}
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Permissions:: |
protected | property | The entity type manager. | |
Permissions:: |
protected | property | The identity channel manager. | |
Permissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
Permissions:: |
public | function | Define permissions for each channel + identity combination. | |
Permissions:: |
public | function | Constructs a CourierMessageController object. | |
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. |