You are here

public function RedirectChecker::canRedirect in Global Redirect 8

Checks access to the route.

Parameters

string $route_name: The current route name.

\Symfony\Component\HttpFoundation\Request $request: The current request.

Return value

bool TRUE if access is granted.

File

src/RedirectChecker.php, line 67
Contains Drupal\globalredirect\RedirectChecker.

Class

RedirectChecker
Redirect checker class.

Namespace

Drupal\globalredirect

Code

public function canRedirect($route_name, Request $request) {
  $do_redirect = TRUE;

  /** @var \Symfony\Component\Routing\Route $route */
  $route = $this->routeProvider
    ->getRouteByName($route_name);
  if ($this->config
    ->get('access_check')) {
    $do_redirect &= $this->accessManager
      ->check($route, $request, $this->account);
  }
  if ($this->config
    ->get('ignore_admin_path')) {
    $do_redirect &= !(bool) $route
      ->getOption('_admin_route');
  }
  return $do_redirect;
}