You are here

protected function CommerceBundleAccessControlHandler::checkAccess in Commerce Core 8.2

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', 'view label', 'update' or 'delete'.

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

Return value

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

Overrides BundleEntityAccessControlHandler::checkAccess

1 call to CommerceBundleAccessControlHandler::checkAccess()
ProductVariationTypeAccessControlHandler::checkAccess in modules/product/src/ProductVariationTypeAccessControlHandler.php
Performs access checks.
1 method overrides CommerceBundleAccessControlHandler::checkAccess()
ProductVariationTypeAccessControlHandler::checkAccess in modules/product/src/ProductVariationTypeAccessControlHandler.php
Performs access checks.

File

src/CommerceBundleAccessControlHandler.php, line 18

Class

CommerceBundleAccessControlHandler
Defines the access control handler for bundles.

Namespace

Drupal\commerce

Code

protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
  if ($operation === 'delete' && $entity
    ->isLocked()) {
    return AccessResult::forbidden()
      ->addCacheableDependency($entity);
  }
  else {
    return parent::checkAccess($entity, $operation, $account);
  }
}