protected function EntityPermissionProviderBase::buildEntityTypePermissions in Entity API 8
Builds permissions for the entity_type granularity.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type.
Return value
array The permissions.
3 calls to EntityPermissionProviderBase::buildEntityTypePermissions()
- EntityPermissionProvider::buildEntityTypePermissions in src/
EntityPermissionProvider.php - Builds permissions for the entity_type granularity.
- EntityPermissionProviderBase::buildPermissions in src/
EntityPermissionProviderBase.php - Builds permissions for the given entity type.
- UncacheableEntityPermissionProvider::buildEntityTypePermissions in src/
UncacheableEntityPermissionProvider.php - Builds permissions for the entity_type granularity.
2 methods override EntityPermissionProviderBase::buildEntityTypePermissions()
- EntityPermissionProvider::buildEntityTypePermissions in src/
EntityPermissionProvider.php - Builds permissions for the entity_type granularity.
- UncacheableEntityPermissionProvider::buildEntityTypePermissions in src/
UncacheableEntityPermissionProvider.php - Builds permissions for the entity_type granularity.
File
- src/
EntityPermissionProviderBase.php, line 115
Class
- EntityPermissionProviderBase
- @internal
Namespace
Drupal\entityCode
protected function buildEntityTypePermissions(EntityTypeInterface $entity_type) {
$entity_type_id = $entity_type
->id();
$has_owner = $entity_type
->entityClassImplements(EntityOwnerInterface::class);
$has_duplicate_form = $entity_type
->hasLinkTemplate('duplicate-form');
$singular_label = $entity_type
->getSingularLabel();
$plural_label = $entity_type
->getPluralLabel();
$permissions = [];
$permissions["create {$entity_type_id}"] = [
'title' => $this
->t('Create @type', [
'@type' => $plural_label,
]),
];
if ($has_owner) {
$permissions["update any {$entity_type_id}"] = [
'title' => $this
->t('Update any @type', [
'@type' => $singular_label,
]),
];
$permissions["update own {$entity_type_id}"] = [
'title' => $this
->t('Update own @type', [
'@type' => $plural_label,
]),
];
if ($has_duplicate_form) {
$permissions["duplicate any {$entity_type_id}"] = [
'title' => $this
->t('Duplicate any @type', [
'@type' => $singular_label,
]),
];
$permissions["duplicate own {$entity_type_id}"] = [
'title' => $this
->t('Duplicate own @type', [
'@type' => $plural_label,
]),
];
}
$permissions["delete any {$entity_type_id}"] = [
'title' => $this
->t('Delete any @type', [
'@type' => $singular_label,
]),
];
$permissions["delete own {$entity_type_id}"] = [
'title' => $this
->t('Delete own @type', [
'@type' => $plural_label,
]),
];
}
else {
$permissions["update {$entity_type_id}"] = [
'title' => $this
->t('Update @type', [
'@type' => $plural_label,
]),
];
if ($has_duplicate_form) {
$permissions["duplicate {$entity_type_id}"] = [
'title' => $this
->t('Duplicate @type', [
'@type' => $plural_label,
]),
];
}
$permissions["delete {$entity_type_id}"] = [
'title' => $this
->t('Delete @type', [
'@type' => $plural_label,
]),
];
}
return $permissions;
}