How can I programatically determine whether a certain user has "view" (or any other operation) permission for a given node?
I'm trying this, but it doesn't seem to be calling the node access hooks, and it's overall pretty ugly:
$node_grant_storage = \Drupal::service('node.grant_storage');
$current_user_has_access = is_a(
$node_grant_storage->access(
$node,
'view',
\Drupal::currentUser()->getAccount()
),
'Drupal\Core\Access\AccessResultAllowed'
);
Ideally I'd like something to return a boolean and not a class (I have no use for the "neutral" option here, I just want to know if a user went into the node/X
page, would they get a 403 or not).