You are here

class Permissions in Mass Contact 8

Defines per-category mass contact permissions.

Hierarchy

Expanded class hierarchy of Permissions

1 file declares its use of Permissions
PermissionsTest.php in tests/src/Kernel/PermissionsTest.php

File

src/Permissions.php, line 11

Namespace

Drupal\mass_contact
View source
class Permissions {
  use StringTranslationTrait;

  /**
   * Generates per-category permissions.
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Permissions::categoryPermissions public function Generates per-category permissions.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.