function NodePreviewAccessCheck::access
Same name in other branches
- 9 core/modules/node/src/Access/NodePreviewAccessCheck.php \Drupal\node\Access\NodePreviewAccessCheck::access()
- 8.9.x core/modules/node/src/Access/NodePreviewAccessCheck.php \Drupal\node\Access\NodePreviewAccessCheck::access()
- 10 core/modules/node/src/Access/NodePreviewAccessCheck.php \Drupal\node\Access\NodePreviewAccessCheck::access()
Checks access to the node preview page.
Parameters
\Drupal\Core\Session\AccountInterface $account: The currently logged in account.
\Drupal\node\NodeInterface $node_preview: The node that is being previewed.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
File
-
core/
modules/ node/ src/ Access/ NodePreviewAccessCheck.php, line 45
Class
- NodePreviewAccessCheck
- Determines access to node previews.
Namespace
Drupal\node\AccessCode
public function access(AccountInterface $account, NodeInterface $node_preview) {
if ($node_preview->isNew()) {
$access_controller = $this->entityTypeManager
->getAccessControlHandler('node');
return $access_controller->createAccess($node_preview->bundle(), $account, [], TRUE);
}
else {
return $node_preview->access('update', $account, TRUE);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.