Dec 03, 2020 in Drupal 8

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;

 

Comments