By dawehner on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
Many entity types just need a single permission to check access in general, like "administer actions".
You can specify the permission on the entity annotation, so in many cases you can avoid a custom entity access control handler.
With entity access control handler
/**
* @EntityType(
* controllers = {
* "access" = "Drupal\example\CustomAccessControlHandler"
* }
* )
*/
class ExampleEntity implements EntityInterface
class CustomAccessControlHandler extends EntityAccessControlHandler {
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
return $account->hasPermission('administer example');
}
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return $account->hasPermission('administer example');
}
}
Without entity access control handler
/**
* @EntityType(
* admin_permission = "administer example"
* )
*/
class ExampleEntity implements EntityInterface
Impacts:
Module developers