case 'update':
// Users can always edit their own account.
$access_result = AccessResult::
allowedIf($account->
id() ==
$entity->
id())->
cachePerUser();
if (!
$access_result->
isAllowed() &&
$access_result instanceof AccessResultReasonInterface
) { $access_result->
setReason("Users can only update their own account, unless they have the 'administer users' permission."
);
} return $access_result;
case 'delete':
// Users with 'cancel account' permission can cancel their own account.
return AccessResult::
allowedIfHasPermission($account, 'cancel account'
) ->
andIf(AccessResult::
allowedIf($account->
id() ==
$entity->
id())->
cachePerUser());
} // No opinion.
return AccessResult::
neutral();
} /**
* {@inheritdoc}
*/
protected function checkFieldAccess($operation, FieldDefinitionInterface
$field_definition, AccountInterface
$account, FieldItemListInterface
$items = NULL
) { // Fields that are not implicitly allowed to administrative users.