You are here

private function RedirectSubscriber::doRedirect in Data Policy 8

Do redirect to the agreement page.

Parameters

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

1 call to RedirectSubscriber::doRedirect()
RedirectSubscriber::checkForRedirection in src/RedirectSubscriber.php
This method is called when the KernelEvents::REQUEST event is dispatched.

File

src/RedirectSubscriber.php, line 286

Class

RedirectSubscriber
Class RedirectSubscriber.

Namespace

Drupal\data_policy

Code

private function doRedirect($event) : void {

  // Set the destination that redirects the user after accepting the
  // data policy agreements.
  $destination = $this
    ->getDestination();

  // Check if there are hooks to invoke that do an override.
  $implementations = $this->moduleHandler
    ->getImplementations('data_policy_destination_alter');
  if (!empty($implementations)) {
    $module = end($implementations);
    $destination = $this->moduleHandler
      ->invoke($module, 'data_policy_destination_alter', [
      $this->currentUser,
      $this
        ->getDestination(),
    ]);
  }
  $url = Url::fromRoute('data_policy.data_policy.agreement', [], [
    'query' => $destination
      ->getAsArray(),
  ]);
  $response = new RedirectResponse($url
    ->toString());
  $event
    ->setResponse($response);
}