class NodePreviewAccessCheck
Same name in other branches
- 9 core/modules/node/src/Access/NodePreviewAccessCheck.php \Drupal\node\Access\NodePreviewAccessCheck
- 8.9.x core/modules/node/src/Access/NodePreviewAccessCheck.php \Drupal\node\Access\NodePreviewAccessCheck
- 10 core/modules/node/src/Access/NodePreviewAccessCheck.php \Drupal\node\Access\NodePreviewAccessCheck
Determines access to node previews.
Hierarchy
- class \Drupal\node\Access\NodePreviewAccessCheck implements \Drupal\Core\Routing\Access\AccessInterface
Expanded class hierarchy of NodePreviewAccessCheck
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 15
Namespace
Drupal\node\AccessView source
class NodePreviewAccessCheck implements AccessInterface {
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs an EntityCreateAccessCheck object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_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 \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
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);
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
NodePreviewAccessCheck::$entityTypeManager | protected | property | The entity type manager service. |
NodePreviewAccessCheck::access | public | function | Checks access to the node preview page. |
NodePreviewAccessCheck::__construct | public | function | Constructs an EntityCreateAccessCheck object. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.