public function UserSwitchController::switchuser in User Switch 8
Switch to new user.
1 string reference to 'UserSwitchController::switchuser'
File
- src/
Controller/ UserSwitchController.php, line 93
Class
- UserSwitchController
- Provides route responses for the Example module.
Namespace
Drupal\userswitch\ControllerCode
public function switchuser($uid) {
if ($this->userswitch
->switchToOther($uid)) {
$message = $this
->t('You are now @user.', [
'@user' => $this->currentUser
->getDisplayName(),
]);
$this->messenger
->addMessage($message);
}
$url = Url::fromRoute('entity.user.canonical', [
'user' => $uid,
])
->toString();
$response = new RedirectResponse($url);
$response
->send();
return new Response();
}