You are here

protected function PetAccessControlHandler::checkAccess in Previewable email templates 8

Same name and namespace in other branches
  1. 8.4 src/PetAccessControlHandler.php \Drupal\pet\PetAccessControlHandler::checkAccess()
  2. 8.3 src/PetAccessControlHandler.php \Drupal\pet\PetAccessControlHandler::checkAccess()

Link the activities to the permissions. checkAccess is called with the $operation as defined in the routing.yml file.

Overrides EntityAccessControlHandler::checkAccess

File

src/PetAccessControlHandler.php, line 18

Class

PetAccessControlHandler

Namespace

Drupal\pet

Code

protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
  switch ($operation) {
    case 'view':
      return AccessResult::allowedIfHasPermission($account, 'view PET entity');
    case 'update':
      return AccessResult::allowedIfHasPermission($account, 'edit PET entity');
    case 'delete':
      return AccessResult::allowedIfHasPermission($account, 'delete PET entity');
  }
  return AccessResult::neutral();
}