protected function CRMCorePermissions::bundlePermissions in CRM Core 8.3
Same name and namespace in other branches
- 8 src/CRMCorePermissions.php \Drupal\crm_core\CRMCorePermissions::bundlePermissions()
- 8.2 src/CRMCorePermissions.php \Drupal\crm_core\CRMCorePermissions::bundlePermissions()
Define per-bundle permissions.
1 call to CRMCorePermissions::bundlePermissions()
- CRMCorePermissions::entityTypePermissions in src/
CRMCorePermissions.php - Return permission names for a given CRM Core entity type.
File
- src/
CRMCorePermissions.php, line 77
Class
- CRMCorePermissions
- Permission callbacks.
Namespace
Drupal\crm_coreCode
protected function bundlePermissions($bundle_name, array $bundle_info, EntityTypeInterface $entity_info) {
$labels = $this
->permissionLabels($entity_info);
$has_owner = $entity_info
->hasKey('owner');
$permissions['create ' . $entity_info
->id() . ' entities of bundle ' . $bundle_name] = [
'title' => $this
->t('Create %bundle @entity_type', [
'@entity_type' => $labels['plural'],
'%bundle' => $bundle_info['label'],
]),
];
if ($has_owner) {
$permissions['edit own ' . $entity_info
->id() . ' entities of bundle ' . $bundle_name] = [
'title' => $this
->t('Edit own %bundle @entity_type', [
'@entity_type' => $labels['plural'],
'%bundle' => $bundle_info['label'],
]),
];
}
$permissions['edit any ' . $entity_info
->id() . ' entity of bundle ' . $bundle_name] = [
'title' => $this
->t('Edit any %bundle @entity_type', [
'@entity_type' => $labels['singular'],
'%bundle' => $bundle_info['label'],
]),
'restrict access' => TRUE,
];
if ($has_owner) {
$permissions['delete own ' . $entity_info
->id() . ' entities of bundle ' . $bundle_name] = [
'title' => $this
->t('Delete own %bundle @entity_type', [
'@entity_type' => $labels['plural'],
'%bundle' => $bundle_info['label'],
]),
];
}
$permissions['delete any ' . $entity_info
->id() . ' entity of bundle ' . $bundle_name] = [
'title' => $this
->t('Delete any %bundle @entity_type', [
'@entity_type' => $labels['singular'],
'%bundle' => $bundle_info['label'],
]),
'restrict access' => TRUE,
];
if ($has_owner) {
$permissions['view own ' . $entity_info
->id() . ' entities of bundle ' . $bundle_name] = [
'title' => $this
->t('View own %bundle @entity_type', [
'@entity_type' => $labels['plural'],
'%bundle' => $bundle_info['label'],
]),
];
}
$permissions['view any ' . $entity_info
->id() . ' entity of bundle ' . $bundle_name] = [
'title' => $this
->t('View any %bundle @entity_type', [
'@entity_type' => $labels['singular'],
'%bundle' => $bundle_info['label'],
]),
'restrict access' => TRUE,
];
return $permissions;
}