You are here

protected function ActivityAccessControlHandler::checkAccess in CRM Core 8

Same name and namespace in other branches
  1. 8.3 modules/crm_core_activity/src/ActivityAccessControlHandler.php \Drupal\crm_core_activity\ActivityAccessControlHandler::checkAccess()
  2. 8.2 modules/crm_core_activity/src/ActivityAccessControlHandler.php \Drupal\crm_core_activity\ActivityAccessControlHandler::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', '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 EntityAccessControlHandler::checkAccess

File

modules/crm_core_activity/src/ActivityAccessControlHandler.php, line 19

Class

ActivityAccessControlHandler
Access control handler for CRM Core Activity entities.

Namespace

Drupal\crm_core_activity

Code

protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
  switch ($operation) {
    case 'view':
      return AccessResult::allowedIfHasPermissions($account, [
        'administer crm_core_activity entities',
        'view any crm_core_activity entity',
        'view any crm_core_activity entity of bundle ' . $entity
          ->bundle(),
      ], 'OR');
    case 'update':
      return AccessResult::allowedIfHasPermissions($account, [
        'administer crm_core_activity entities',
        'edit any crm_core_activity entity',
        'edit any crm_core_activity entity of bundle ' . $entity
          ->bundle(),
      ], 'OR');
    case 'delete':
      return AccessResult::allowedIfHasPermissions($account, [
        'administer crm_core_activity entities',
        'delete any crm_core_activity entity',
        'delete any crm_core_activity entity of bundle ' . $entity
          ->bundle(),
      ], 'OR');
  }
}