List of AccessResult types in drupal 8 & 9

Drupal is using more and more AccessResult objects for access checking. Here is a list of all the access results available.

neutral
allowed
forbidden
allowedIf
forbiddenIf
allowedIfHasPermission
allowedIfHasPermissions
isAllowed
isForbidden
isNeutral
orIf
andIf

This way, we can secure access to entities:

use Drupal\Core\Access\AccessResult;

$access = AccessResult::allowedIf($node->access('view'));
return $access;

 

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!