You are here

public function Permissions::sendMessageToChannels in Courier 8

Same name and namespace in other branches
  1. 2.x courier_message_composer/src/Permissions.php \Drupal\courier_message_composer\Permissions::sendMessageToChannels()

Define permissions for each channel + identity combination.

Return value

array

1 string reference to 'Permissions::sendMessageToChannels'
courier_message_composer.permissions.yml in courier_message_composer/courier_message_composer.permissions.yml
courier_message_composer/courier_message_composer.permissions.yml

File

courier_message_composer/src/Permissions.php, line 60

Class

Permissions
Define a permission generator for Courier Message Composer.

Namespace

Drupal\courier_message_composer

Code

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;
}