Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
A website might have more than one login destination url based on the request parameters. So let other module alter the redirect Url.
Comment | File | Size | Author |
---|---|---|---|
#13 | 2700797-13-provide-hook-functionality.patch | 3.24 KB | pingers |
#4 | 2700797-provide-hook-functionality.patch | 3.94 KB | b.ravanbakhsh |
Comments
Comment #2
b.ravanbakhshComment #3
b.ravanbakhshComment #4
b.ravanbakhshComment #5
b.ravanbakhshComment #6
b.ravanbakhshComment #7
pfrenssenSeems a bit strange to me to introduce new hooks in Drupal 8 now that we have EventSubscribers which have lots of advantages over hooks. Hooks are probably going to go away completely in D9, so if we introduce something new then let's go with EventSubscribers immediately.
Comment #8
shrop CreditAttribution: shrop at Mediacurrent commentedAgree with @pfrenssen. EventSubscribers are really slick and provide a supported future path for new versions of Drupal, as he mentioned. Love to hear if there is a good reason to consider adding hooks to the D8 version.
Comment #9
b.ravanbakhshA website might have more than one login destination based on how the user logs in such as using CAS, drupal login form, custom form, another custom form and ... but $config->get('redirect_authenticated_users_to') is single.
Adding the ability to customise role-based 'redirect_authenticated_users_to' URLs would be my suggestion.
Comment #10
shrop CreditAttribution: shrop at Mediacurrent commented@b.ravanbakhsh: That sounds like a pretty good use case. Thanks for the thought on that! Is that the feature that you drove you to thinking hook functionality?
If we add module hook capabilities to the 8.x release, it will be come a feature that is depended on and removal later would be a challenge, probably forcing a new 8.x branch like 8.x-2.x. With that, are there ways to accomplish this by building in a role based redirection function with EventSubcribers or maybe a submodule that is part of the Redirect 403 to User Login module?
Not just asking you, but anyone with thoughts around this.
Comment #11
shrop CreditAttribution: shrop at Mediacurrent commentedI had a conversation with @DamienMcKenna on this subject and he had a great suggestion/compromise. What if we add
@deprecated
in the related docblock? We could mention that it will be removed in the Drupal 9 version and suggest using EventSubscribers instead.I think this would give everyone notice about future plans and flexibility.
Reference: https://www.drupal.org/core/deprecation
New patch?
Comment #12
shrop CreditAttribution: shrop at Mediacurrent commentedComment #13
pingers CreditAttribution: pingers as a volunteer and at University of Adelaide commentedHere's a re-roll against HEAD.
Comment #15
Nixou CreditAttribution: Nixou at Actency commentedAs @pfrenssen and @shrop said above, adding hook is not what is expected of us.
Hooks will be remove in the future, replaced by Event Subscribers.
Thanks you all for your work around the hook, but I wrote another patch based on an Event Subscriber which we do the same job.
Redirect Url can now be override using this subscriber.
Below is an Event Subscriber example to implement this override :
your_module.services.yml :
YourModuleSubscriber.php :
Comment #16
estoyausente@Nixou This information is too valuable to leave in a issue comment, where can I move it? Has the module any unlinked guide or can I add to the readme? I think that include it in readme is not the correct way but the module is not too big and create a documentation page maybe is overkill.
Comment #17
Nixou CreditAttribution: Nixou at Actency commentedIf we add this code snippet in the readme file, it could become unreadable.
So a documentation page will be better certainly.
However it needs some access rights to create a guide for the module and I have not.
I'll ask @bdone to determine how we can achieve this.
Thanks for the proposition.
Comment #18
estoyausenteGreat! thank for considering it!