class MessagePermissions in Message UI 8
Defines a class containing permission callbacks.
Hierarchy
- class \Drupal\message_ui\MessagePermissions uses StringTranslationTrait
Expanded class hierarchy of MessagePermissions
1 file declares its use of MessagePermissions
- MessageUiPermissionsTest.php in tests/
src/ Functional/ MessageUiPermissionsTest.php
File
- src/
MessagePermissions.php, line 11
Namespace
Drupal\message_uiView source
class MessagePermissions {
use StringTranslationTrait;
/**
* Gets an array of message type permissions.
*
* @return array
* The message template permissions.
*
* @see \Drupal\user\PermissionHandlerInterface::getPermissions()
*/
public function messageTemplatePermissions() {
$perms = [];
// Generate node permissions for all message templates.
foreach (MessageTemplate::loadMultiple() as $template) {
$perms += $this
->buildPermissions($template);
}
return $perms;
}
/**
* Builds a standard list of message permissions for a given template.
*
* @param \Drupal\message\Entity\MessageTemplate $template
* The machine name of the message template.
*
* @return array
* An array of permission names and descriptions.
*/
protected function buildPermissions(MessageTemplate $template) {
$template_params = [
'%template_name' => $template
->label(),
];
return [
'view ' . $template
->id() . ' message' => [
'title' => $this
->t('%template_name: View a message instance', $template_params),
],
'edit ' . $template
->id() . ' message' => [
'title' => $this
->t('%template_name: Edit a message instance', $template_params),
],
'create ' . $template
->id() . ' message' => [
'title' => $this
->t('%template_name: Create a new message instance', $template_params),
],
'delete ' . $template
->id() . ' message' => [
'title' => $this
->t('%template_name: Delete a message instance', $template_params),
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MessagePermissions:: |
protected | function | Builds a standard list of message permissions for a given template. | |
MessagePermissions:: |
public | function | Gets an array of message 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. |