function UserAuthenticationController::getRequestFormat

Same name and namespace in other branches
  1. 9 core/modules/user/src/Controller/UserAuthenticationController.php \Drupal\user\Controller\UserAuthenticationController::getRequestFormat()
  2. 8.9.x core/modules/user/src/Controller/UserAuthenticationController.php \Drupal\user\Controller\UserAuthenticationController::getRequestFormat()
  3. 11.x core/modules/user/src/Controller/UserAuthenticationController.php \Drupal\user\Controller\UserAuthenticationController::getRequestFormat()

Gets the format of the current request.

Parameters

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

Return value

string The format of the request.

2 calls to UserAuthenticationController::getRequestFormat()
UserAuthenticationController::login in core/modules/user/src/Controller/UserAuthenticationController.php
Logs in a user.
UserAuthenticationController::resetPassword in core/modules/user/src/Controller/UserAuthenticationController.php
Resets a user password.

File

core/modules/user/src/Controller/UserAuthenticationController.php, line 352

Class

UserAuthenticationController
Provides controllers for login, login status and logout via HTTP requests.

Namespace

Drupal\user\Controller

Code

protected function getRequestFormat(Request $request) {
    $format = $request->getRequestFormat();
    if (!in_array($format, $this->serializerFormats)) {
        throw new BadRequestHttpException("Unrecognized format: {$format}.");
    }
    return $format;
}

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