function AuthenticationManager::getProvider

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Authentication/AuthenticationManager.php \Drupal\Core\Authentication\AuthenticationManager::getProvider()
  2. 10 core/lib/Drupal/Core/Authentication/AuthenticationManager.php \Drupal\Core\Authentication\AuthenticationManager::getProvider()
  3. 11.x core/lib/Drupal/Core/Authentication/AuthenticationManager.php \Drupal\Core\Authentication\AuthenticationManager::getProvider()

Returns the id of the authentication provider for a request.

Parameters

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

Return value

string|null The id of the first authentication provider which applies to the request. If no application detects appropriate credentials, then NULL is returned.

3 calls to AuthenticationManager::getProvider()
AuthenticationManager::applies in core/lib/Drupal/Core/Authentication/AuthenticationManager.php
Checks whether suitable authentication credentials are on the request.
AuthenticationManager::appliesToRoutedRequest in core/lib/Drupal/Core/Authentication/AuthenticationManager.php
Checks whether the authentication method is allowed on a given route.
AuthenticationManager::authenticate in core/lib/Drupal/Core/Authentication/AuthenticationManager.php
Authenticates the user.

File

core/lib/Drupal/Core/Authentication/AuthenticationManager.php, line 101

Class

AuthenticationManager
Manager for authentication.

Namespace

Drupal\Core\Authentication

Code

protected function getProvider(Request $request) {
    foreach ($this->authCollector
        ->getSortedProviders() as $provider_id => $provider) {
        if ($provider->applies($request)) {
            return $provider_id;
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.