NodeViewPermissionsPermissions.php in Node View Permissions 8
File
src/NodeViewPermissionsPermissions.php
View source
<?php
namespace Drupal\node_view_permissions;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\node\Entity\NodeType;
class NodeViewPermissionsPermissions {
use StringTranslationTrait;
public function permissions() {
$permissions = [];
$nodeTypes = NodeType::loadMultiple();
foreach ($nodeTypes as $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;
}
}