5 use Drupal\Core\Access\AccessResult;
6 use Drupal\Core\Entity\EntityAccessControlHandler;
7 use Drupal\Core\Entity\EntityInterface;
8 use Drupal\Core\Session\AccountInterface;
11 * Defines the access control handler for the user role entity type.
13 * @see \Drupal\user\Entity\Role
15 class RoleAccessControlHandler extends EntityAccessControlHandler {
20 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
23 if ($entity->id() == RoleInterface::ANONYMOUS_ID || $entity->id() == RoleInterface::AUTHENTICATED_ID) {
24 return AccessResult::forbidden();
28 return parent::checkAccess($entity, $operation, $account);