public function NodePreviewAccessCheck::access in Drupal 10
Same name and namespace in other branches
- 8 core/modules/node/src/Access/NodePreviewAccessCheck.php \Drupal\node\Access\NodePreviewAccessCheck::access()
- 9 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);
}
}