You are here

protected function EntityAccessControlHandler::checkAccess in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php \Drupal\Core\Entity\EntityAccessControlHandler::checkAccess()

Performs access checks.

This method is supposed to be overwritten by extending classes that do their own custom access checking.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for which to check access.

string $operation: The entity operation. Usually one of 'view', 'update' or 'delete'.

\Drupal\Core\Session\AccountInterface $account: The user for which to check access.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

12 calls to EntityAccessControlHandler::checkAccess()
BlockAccessControlHandler::checkAccess in core/modules/block/src/BlockAccessControlHandler.php
Performs access checks.
BlockContentAccessControlHandler::checkAccess in core/modules/block_content/src/BlockContentAccessControlHandler.php
Performs access checks.
ContactFormAccessControlHandler::checkAccess in core/modules/contact/src/ContactFormAccessControlHandler.php
Performs access checks.
DateFormatAccessControlHandler::checkAccess in core/modules/system/src/DateFormatAccessControlHandler.php
Performs access checks.
EntityAccessControlHandler::access in core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
Checks access to an operation on a given entity or entity translation.

... See full list

23 methods override EntityAccessControlHandler::checkAccess()
BlockAccessControlHandler::checkAccess in core/modules/block/src/BlockAccessControlHandler.php
Performs access checks.
BlockContentAccessControlHandler::checkAccess in core/modules/block_content/src/BlockContentAccessControlHandler.php
Performs access checks.
CommentAccessControlHandler::checkAccess in core/modules/comment/src/CommentAccessControlHandler.php
Performs access checks.
ConfigTestAccessControlHandler::checkAccess in core/modules/config/tests/config_test/src/ConfigTestAccessControlHandler.php
Performs access checks.
ContactFormAccessControlHandler::checkAccess in core/modules/contact/src/ContactFormAccessControlHandler.php
Performs access checks.

... See full list

File

core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php, line 134
Contains \Drupal\Core\Entity\EntityAccessControlHandler.

Class

EntityAccessControlHandler
Defines a default implementation for entity access control handler.

Namespace

Drupal\Core\Entity

Code

protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
  if ($operation == 'delete' && $entity
    ->isNew()) {
    return AccessResult::forbidden()
      ->cacheUntilEntityChanges($entity);
  }
  if ($admin_permission = $this->entityType
    ->getAdminPermission()) {
    return AccessResult::allowedIfHasPermission($account, $this->entityType
      ->getAdminPermission());
  }
  else {

    // No opinion.
    return AccessResult::neutral();
  }
}