You are here

public function AuthenticationManager::appliesToRoutedRequest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Authentication/AuthenticationManager.php \Drupal\Core\Authentication\AuthenticationManager::appliesToRoutedRequest()

Checks whether the authentication method is allowed on a given route.

While authentication itself is run before routing, this method is called after routing, hence RouteMatch is available and can be used to inspect route options.

Parameters

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

bool $authenticated: Whether or not the request is authenticated.

Return value

bool TRUE if an authentication method is allowed on the request, otherwise FALSE.

Overrides AuthenticationProviderFilterInterface::appliesToRoutedRequest

File

core/lib/Drupal/Core/Authentication/AuthenticationManager.php, line 66
Contains \Drupal\Core\Authentication\AuthenticationManager.

Class

AuthenticationManager
Manager for authentication.

Namespace

Drupal\Core\Authentication

Code

public function appliesToRoutedRequest(Request $request, $authenticated) {
  $result = FALSE;
  if ($authenticated) {
    $result = $this
      ->applyFilter($request, $authenticated, $this
      ->getProvider($request));
  }
  else {
    foreach ($this->authCollector
      ->getSortedProviders() as $provider_id => $provider) {
      if ($this
        ->applyFilter($request, $authenticated, $provider_id)) {
        $result = TRUE;
        break;
      }
    }
  }
  return $result;
}