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?

Donate and get more free time-saving code on this website in the future.