You are here

private function KernelEventListener::handleAccessToTaxonomyTermViewsPages in Permissions by Term 8.2

1 call to KernelEventListener::handleAccessToTaxonomyTermViewsPages()
KernelEventListener::onKernelRequest in src/Listener/KernelEventListener.php
Access restriction on kernel request.

File

src/Listener/KernelEventListener.php, line 155

Class

KernelEventListener
Class KernelEventListener.

Namespace

Drupal\permissions_by_term\Listener

Code

private function handleAccessToTaxonomyTermViewsPages() {
  $url_object = \Drupal::service('path.validator')
    ->getUrlIfValid(\Drupal::service('path.current')
    ->getPath());
  if ($url_object instanceof Url && $url_object
    ->getRouteName() === 'entity.taxonomy_term.canonical') {
    $route_parameters = $url_object
      ->getrouteParameters();
    $termLangcode = \Drupal::languageManager()
      ->getCurrentLanguage()
      ->getId();
    if (!$this->accessCheckService
      ->isAccessAllowedByDatabase($route_parameters['taxonomy_term'], \Drupal::currentUser()
      ->id(), $termLangcode)) {
      $this->pageCacheKillSwitch
        ->trigger();
      throw new AccessDeniedHttpException();
    }
  }
}