OrgPermissions.php in RedHen CRM 8
File
modules/redhen_org/src/OrgPermissions.php
View source
<?php
namespace Drupal\redhen_org;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\redhen_org\Entity\OrgType;
class OrgPermissions {
use StringTranslationTrait;
public function OrgTypePermissions() {
$perms = [];
foreach (OrgType::loadMultiple() as $type) {
$perms += $this
->buildPermissions($type);
}
return $perms;
}
protected function buildPermissions(OrgType $org_type) {
$type_id = $org_type
->id();
$type_params = [
'%type' => $org_type
->label(),
];
return [
"add {$type_id} org" => [
'title' => $this
->t('%type: Add org', $type_params),
],
"view active {$type_id} org" => [
'title' => $this
->t('%type: View active orgs', $type_params),
],
"view inactive {$type_id} org" => [
'title' => $this
->t('%type: View inactive orgs', $type_params),
],
"edit {$type_id} org" => [
'title' => $this
->t('%type: Edit orgs', $type_params),
],
"delete {$type_id} org" => [
'title' => $this
->t('%type: Delete orgs', $type_params),
],
];
}
}