SimpleAccessPermissions.php in Simple Access 8.3
File
src/SimpleAccessPermissions.php
View source
<?php
namespace Drupal\simple_access;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\node\Entity\NodeType;
class SimpleAccessPermissions {
use StringTranslationTrait;
public function nodeTypePermissions() {
$perms = [];
foreach (NodeType::loadMultiple() as $type) {
$perms += $this
->buildPermissions($type);
}
return $perms;
}
protected function buildPermissions(NodeType $type) {
$type_id = $type
->id();
$type_params = [
'%type_name' => $type
->label(),
];
return [
"assign groups to {$type_id} nodes" => [
'title' => $this
->t('%type_name: Assign groups', $type_params),
],
"assign profiles to {$type_id} nodes" => [
'title' => $this
->t('%type_name: Assign profiles', $type_params),
],
"assign owner permissions for {$type_id}" => [
'title' => $this
->t('%type_name: Assign owner permissions', $type_params),
],
];
}
}