You are here

public function Redirect::checkForRedirection in Open Social 8.3

Same name and namespace in other branches
  1. 8.9 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect::checkForRedirection()
  2. 8.2 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect::checkForRedirection()
  3. 8.4 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect::checkForRedirection()
  4. 8.5 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect::checkForRedirection()
  5. 8.6 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect::checkForRedirection()
  6. 8.7 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect::checkForRedirection()
  7. 8.8 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect::checkForRedirection()
  8. 10.0.x modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect::checkForRedirection()
  9. 10.1.x modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect::checkForRedirection()

This method is called when the KernelEvents::REQUEST event is dispatched.

Parameters

\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The event.

File

modules/custom/social_gdpr/src/Subscriber/Redirect.php, line 61

Class

Redirect
Class Redirect.

Namespace

Drupal\social_gdpr\Subscriber

Code

public function checkForRedirection(GetResponseEvent $event) {
  if ($this->routeMatch
    ->getRouteName() != 'entity.data_policy.version_history') {
    return;
  }
  if ($this->currentUser
    ->id() == 1 || !$this->currentUser
    ->hasPermission('view all data policy revisions')) {
    return;
  }
  $url = Url::fromRoute('social_gdpr.data_policy.revisions');
  $response = new RedirectResponse($url
    ->toString());
  $event
    ->setResponse($response);
}