You are here

class NodePreviewAccessCheck in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Access/NodePreviewAccessCheck.php \Drupal\node\Access\NodePreviewAccessCheck

Determines access to node previews.

Hierarchy

Expanded class hierarchy of NodePreviewAccessCheck

Related topics

1 string reference to 'NodePreviewAccessCheck'
node.services.yml in core/modules/node/node.services.yml
core/modules/node/node.services.yml
1 service uses NodePreviewAccessCheck
access_check.node.preview in core/modules/node/node.services.yml
Drupal\node\Access\NodePreviewAccessCheck

File

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

Namespace

Drupal\node\Access
View source
class NodePreviewAccessCheck implements AccessInterface {

  /**
   * The entity manager.
   *
   * @var \Drupal\Core\Entity\EntityManagerInterface
   */
  protected $entityManager;

  /**
   * Constructs a EntityCreateAccessCheck object.
   *
   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
   *   The entity manager.
   */
  public function __construct(EntityManagerInterface $entity_manager) {
    $this->entityManager = $entity_manager;
  }

  /**
   * Checks access to the node preview page.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The currently logged in account.
   * @param \Drupal\node\NodeInterface $node_preview
   *   The node that is being previewed.
   *
   * @return string
   *   A \Drupal\Core\Access\AccessInterface constant value.
   */
  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);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
NodePreviewAccessCheck::$entityManager protected property The entity manager.
NodePreviewAccessCheck::access public function Checks access to the node preview page.
NodePreviewAccessCheck::__construct public function Constructs a EntityCreateAccessCheck object.