You are here

public function NodePreviewAccessCheck::access in Drupal 8

Same name and namespace in other branches
  1. 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 52

Class

NodePreviewAccessCheck
Determines access to node previews.

Namespace

Drupal\node\Access

Code

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);
  }
}