function UserController::userPage

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

Redirects users to their profile page.

This controller assumes that it is only invoked for authenticated users. This is enforced for the 'user.page' route with the '_user_is_logged_in' requirement.

Attributes

#[Route(path: '/user', name: 'user.page', requirements: [ '_user_is_logged_in' => 'TRUE', ], defaults: [ '_title' => new TranslatableMarkup('My account'), ])]

Return value

\Symfony\Component\HttpFoundation\RedirectResponse Returns a redirect to the profile of the currently logged in user.

File

core/modules/user/src/Controller/UserController.php, line 392

Class

UserController
Controller routines for user routes.

Namespace

Drupal\user\Controller

Code

public function userPage() {
  return $this->redirect('entity.user.canonical', [
    'user' => $this->currentUser()
      ->id(),
  ]);
}

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