NodeTypeAccessControlHandler.php
Same filename in other branches
Namespace
Drupal\nodeFile
-
core/
modules/ node/ src/ NodeTypeAccessControlHandler.php
View source
<?php
namespace Drupal\node;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
/**
* Defines the access control handler for the node type entity type.
*
* @see \Drupal\node\Entity\NodeType
*/
class NodeTypeAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
switch ($operation) {
case 'view':
return AccessResult::allowedIfHasPermission($account, 'access content');
case 'delete':
if ($entity->isLocked()) {
return AccessResult::forbidden()->addCacheableDependency($entity);
}
else {
return parent::checkAccess($entity, $operation, $account)->addCacheableDependency($entity);
}
break;
default:
return parent::checkAccess($entity, $operation, $account);
}
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
NodeTypeAccessControlHandler | Defines the access control handler for the node type entity type. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.