class NodeViewPermissionsPermissions in Node View Permissions 8
Class definition.
@category NodeViewPermissionsPermissions
@package Access Control
Hierarchy
- class \Drupal\node_view_permissions\NodeViewPermissionsPermissions uses StringTranslationTrait
Expanded class hierarchy of NodeViewPermissionsPermissions
File
- src/
NodeViewPermissionsPermissions.php, line 15
Namespace
Drupal\node_view_permissionsView source
class NodeViewPermissionsPermissions {
use StringTranslationTrait;
/**
* Permission function.
*
* Added the permissions.
*/
public function permissions() {
$permissions = [];
$nodeTypes = NodeType::loadMultiple();
foreach ($nodeTypes as $nodeType) {
/** @var \Drupal\node\Entity\NodeType $nodeType */
$permission = 'view any ' . $nodeType
->id() . ' content';
$permissions[$permission] = [
'title' => $this
->t('<em>@type_label</em>: View any content', [
'@type_label' => $nodeType
->label(),
]),
];
$permission = 'view own ' . $nodeType
->id() . ' content';
$permissions[$permission] = [
'title' => $this
->t('<em>@type_label</em>: View own content', [
'@type_label' => $nodeType
->label(),
]),
];
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
NodeViewPermissionsPermissions:: |
public | function | Permission function. | |
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. |