class CampaignMonitorCampaignPermissions in Campaign Monitor 8
Provides dynamic permissions for nodes of different types.
Hierarchy
- class \Drupal\campaignmonitor_campaign\CampaignMonitorCampaignPermissions uses UrlGeneratorTrait, StringTranslationTrait
Expanded class hierarchy of CampaignMonitorCampaignPermissions
File
- modules/
campaignmonitor_campaign/ src/ CampaignMonitorCampaignPermissions.php, line 12
Namespace
Drupal\campaignmonitor_campaignView source
class CampaignMonitorCampaignPermissions {
use StringTranslationTrait;
use UrlGeneratorTrait;
/**
* Returns an array of node type permissions.
*
* @return array
* The node type permissions.
*
* @see \Drupal\user\PermissionHandlerInterface::getPermissions()
*/
public function campaignMonitorPermissions() {
$perms = [];
// Generate node permissions for all node types.
foreach (NodeType::loadMultiple() as $type) {
if (campaignmonitor_campaign_type_is_configured($type
->id())) {
$perms += $this
->buildPermissions($type);
}
}
return $perms;
}
/**
* Returns a list of node permissions for a given node type.
*
* @param \Drupal\node\Entity\NodeType $type
* The node type.
*
* @return array
* An associative array of permission names and descriptions.
*/
protected function buildPermissions(NodeType $type) {
$type_id = $type
->id();
$type_params = [
'%type_name' => $type
->label(),
];
return [
"send {$type_id} campaigns" => [
'title' => $this
->t('%type_name: Send Campaign', $type_params),
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CampaignMonitorCampaignPermissions:: |
protected | function | Returns a list of node permissions for a given node type. | |
CampaignMonitorCampaignPermissions:: |
public | function | Returns an array of node type 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. |