Commit 8512cbe9 authored by George's avatar George
Browse files

Issue #3143145 by SadySierralta: Redirect to user/{uid}/edit.

parent 2577d653
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\disable_user_view\Controller;

use Drupal\user\Controller\UserController;
use Drupal\user\UserInterface;

/**
 * Controller routines for user routes.
@@ -10,18 +11,18 @@ use Drupal\user\Controller\UserController;
class UserEditController extends UserController {

  /**
   * Redirects users to their profile page.
   * Redirects users to their profile edit page or the user you are trying to access.
   *
   * 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.
   *
   * @return \Symfony\Component\HttpFoundation\RedirectResponse
   *   Returns a redirect to the profile of the currently logged in user.
   *   Returns a redirect to the profile edit form of the currently logged in
   *   user or the user you are trying to access.
   */
  public function userPage() {
    return $this->redirect('entity.user.edit_form', [
      'user' => $this->currentUser()->id(),
    ]);
  public function userPage(UserInterface $user = NULL) {
    $uid = !empty($user) ? $user->id() : $this->currentUser()->id();
    return $this->redirect('entity.user.edit_form', ['user' => $uid]);
  }
}