NodePreviewAccessCheck::access

public NodePreviewAccessCheck::access(AccountInterface $account, NodeInterface $node_preview)

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 45

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);
  }
}
doc_Drupal
2016-10-29 09:31:02
Comments
Leave a Comment

Please login to continue.