You are here

function tca_entity_access in Token Content Access 2.0.x

Same name and namespace in other branches
  1. 8 tca.module \tca_entity_access()

Implements hook_entity_access().

File

./tca.module, line 65
Contains tca.module.

Code

function tca_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
  $neutral = AccessResult::neutral()
    ->addCacheableDependency($entity)
    ->addCacheContexts([
    'url.path',
  ]);
  if ($operation !== 'view') {
    return $neutral;
  }
  $user_token = \Drupal::request()->query
    ->get('tca');
  return \Drupal::service('tca.tca_access_check')
    ->access($entity, $user_token, $account);
}