class MailingListPermissions in Mailing List 8
Provides dynamic permissions for each mailing list.
Hierarchy
- class \Drupal\mailing_list\MailingListPermissions uses UrlGeneratorTrait, StringTranslationTrait
Expanded class hierarchy of MailingListPermissions
File
- src/
MailingListPermissions.php, line 12
Namespace
Drupal\mailing_listView source
class MailingListPermissions {
use StringTranslationTrait;
use UrlGeneratorTrait;
/**
* Returns an array of mailing list permissions.
*
* @return array
* The mailing list type permissions.
*/
public function mailListPermissions() {
$perms = [];
// Generate mailing list permissions for each list.
foreach (MailingList::loadMultiple() as $list) {
$perms += $this
->buildPermissions($list);
}
return $perms;
}
/**
* Returns a list of mailing list permissions for a given list.
*
* @param \Drupal\mailing_list\Entity\MailingList $list
* The mailing list.
*
* @return array
* An associative array of permission names and descriptions.
*/
protected function buildPermissions(MailingList $list) {
$list_id = $list
->id();
$list_params = [
'%list_name' => $list
->label(),
];
return [
"subscribe to {$list_id} mailing list" => [
'title' => $this
->t('Subscribe to %list_name mailing list', $list_params),
],
"access inactive {$list_id} mailing list subscriptions" => [
'title' => $this
->t('%list_name: access inactive subscriptions', $list_params),
],
"view any {$list_id} mailing list subscriptions" => [
'title' => $this
->t('%list_name: view any subscriptions', $list_params),
],
"update any {$list_id} mailing list subscriptions" => [
'title' => $this
->t('%list_name: edit any subscriptions', $list_params),
],
"delete any {$list_id} mailing list subscriptions" => [
'title' => $this
->t('%list_name: delete any subscriptions', $list_params),
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MailingListPermissions:: |
protected | function | Returns a list of mailing list permissions for a given list. | |
MailingListPermissions:: |
public | function | Returns an array of mailing list permissions. | |
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. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Returns a redirect response object for the specified route. | 3 |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |