I want to override the user.login
route that points to the default login page.
I.e. I want that a user who presses the default "Log in" link for the site to be directed to a node that provides some help (where the user can click on a link and arrive at the standard log-in form).
Say that the path I want to redirect to is /node/42
. How can I find out what route to return for a specific node?
I believe that the right place to do this in Drupal 9 is to override the getRouteName()
function the in the LoginLogoutMenuLink
class. So I'm trying to create something like this.
public function getRouteName() {
if ($this->currentUser->isAuthenticated()) {
return 'user.logout';
}
else {
return '- What to put here? - ';
}
}
I've searched a lot, and some people say that the route for nodes are entity.node.canonical
. But that does not solve it for me. I think that the route for a specific node also need to have the nid
in there somewhere.
getRouteParameters()
to return the parameter array with the node id.