You are here

public function ElfController::elfRedirect in External Links Filter 8

Redirect the browser to the external URL from $_GET['url'].

Return value

\Symfony\Component\HttpFoundation\RedirectResponse The redirect response.

1 string reference to 'ElfController::elfRedirect'
elf.routing.yml in ./elf.routing.yml
elf.routing.yml

File

src/Controller/ElfController.php, line 60

Class

ElfController
Provides route controllers for External Link Filter.

Namespace

Drupal\elf\Controller

Code

public function elfRedirect() {
  $url = $this->request
    ->get('url');
  $key = $this->request
    ->get('key');

  // Works as a broken link if no valid arguments found.
  if (!$url || !$key || $key != $this->elfManager
    ->getRedirectUrl($url)
    ->getOption('query')['key']) {
    throw new NotFoundHttpException();
  }

  // Perform the redirection to the external URL.
  return new TrustedRedirectResponse($url);
}