You are here

protected function RedirectRepository::findByRedirect in Redirect 8

Helper function to find recursive redirects.

Parameters

\Drupal\redirect\Entity\Redirect: The redirect object.

string $language: The language to use.

1 call to RedirectRepository::findByRedirect()
RedirectRepository::findMatchingRedirect in src/RedirectRepository.php
Gets a redirect for given path, query and language.

File

src/RedirectRepository.php, line 115

Class

RedirectRepository

Namespace

Drupal\redirect

Code

protected function findByRedirect(Redirect $redirect, $language) {
  $uri = $redirect
    ->getRedirectUrl();
  $base_url = \Drupal::request()
    ->getBaseUrl();
  $generated_url = $uri
    ->toString(TRUE);
  $path = ltrim(substr($generated_url
    ->getGeneratedUrl(), strlen($base_url)), '/');
  $query = $uri
    ->getOption('query') ?: [];
  $return_value = $this
    ->findMatchingRedirect($path, $query, $language);
  return $return_value ? $return_value
    ->addCacheableDependency($generated_url) : $return_value;
}