You are here

public function NodePreviewAccessCheck::access in Zircon Profile 8.0

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

string A \Drupal\Core\Access\AccessInterface constant value.

File

core/modules/node/src/Access/NodePreviewAccessCheck.php, line 50
Contains \Drupal\node\Access\NodePreviewAccessCheck.

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->entityManager
      ->getAccessControlHandler('node');
    return $access_controller
      ->createAccess($node_preview
      ->bundle(), $account, [], TRUE);
  }
  else {
    return $node_preview
      ->access('update', $account, TRUE);
  }
}