You are here

public function Permissions::categoryPermissions in Mass Contact 8

Generates per-category permissions.

1 string reference to 'Permissions::categoryPermissions'
mass_contact.permissions.yml in ./mass_contact.permissions.yml
mass_contact.permissions.yml

File

src/Permissions.php, line 18

Class

Permissions
Defines per-category mass contact permissions.

Namespace

Drupal\mass_contact

Code

public function categoryPermissions() {
  $permissions = [];

  /** @var \Drupal\mass_contact\Entity\MassContactCategoryInterface $category */
  foreach (MassContactCategory::loadMultiple() as $category) {
    $permissions["mass contact send to users in the {$category->id()} category"] = [
      'title' => $this
        ->t('Send to users in the %category category', [
        '%category' => $category
          ->label(),
      ]),
      'description' => $this
        ->t('Allows the user to send messages to the users in the %category category', [
        '%category' => $category
          ->label(),
      ]),
    ];
  }
  return $permissions;
}