![]() * Event subscriber subscribing to KernelEvents::REQUEST. Use Symfony\Component\EventDispatcher\EventSubscriberInterface Use Symfony\Component\HttpKernel\Event\GetResponseEvent Use Symfony\Component\HttpKernel\KernelEvents But when an anonymous user clicks on flag than such user should be redirected to the login page. I want these flags to be displayed to all users (whether logged in or not). Currently it is displayed only to the users who are logged in (authenticated user). Use Symfony\Component\HttpFoundation\RedirectResponse I want to display this flag to anonymous users too. namespace Drupal\mymodule\EventSubscriber ![]() Then add RedirectAnonymousSubscriber.php for your custom event subscriber in your module in the /src/EventSubscriber/ folder. To test this module fast in a fresh install, Drupal's quick-start might come in handy.You can test a user's status very early with event subscriber in a custom module that subscribes to KernelEvents::REQUEST.įirst, you register the event subscriber in in your module folder: services:Ĭlass: Drupal\mymodule\EventSubscriber\RedirectAnonymousSubscriber You can find the previous Drupal 8 code here, and we also found the Anonymous login module, but both didn't work in our Drupal 9 (then beta) install. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |