function UserAuthenticationController::create

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

Overrides ControllerBase::create

File

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

Class

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

Namespace

Drupal\user\Controller

Code

public static function create(ContainerInterface $container) {
    if ($container->hasParameter('serializer.formats') && $container->has('serializer')) {
        $serializer = $container->get('serializer');
        $formats = $container->getParameter('serializer.formats');
    }
    else {
        $formats = [
            'json',
        ];
        $encoders = [
            new JsonEncoder(),
        ];
        $serializer = new Serializer([], $encoders);
    }
    return new static($container->get('user.flood_control'), $container->get('entity_type.manager')
        ->getStorage('user'), $container->get('csrf_token'), $container->get('user.auth'), $container->get('router.route_provider'), $serializer, $formats, $container->get('logger.factory')
        ->get('user'));
}

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