Problem/Motivation
When using Redirect after logout in conjunction with Hook event dispatcher, a TypeError is thrown when accessing its configuration form :
TypeError: Drupal\redirect_after_logout\Form\RedirectLogoutSettings::__construct(): Argument #3 ($module_handler) must be of type Drupal\Core\Extension\ModuleHandler, Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler given, called in /app/web/modules/contrib/redirect_after_logout/src/Form/RedirectLogoutSettings.php on line 78 in Drupal\redirect_after_logout\Form\RedirectLogoutSettings->__construct() (line 59 of modules/contrib/redirect_after_logout/src/Form/RedirectLogoutSettings.php).
Because Hook event dispatcher overrides the ModuleHandler service, a HookEventDispatcherModuleHandler is returned.
Steps to reproduce
Install both modules and access the config form at /admin/config/system/redirect_after_logout
Proposed resolution
The RedirectLogoutSettings form incorrectly uses ModuleHandler as a dependency, it should use ModuleHandlerInterface.
The attached patch addresses this by replacing the concrete class with the interface.
Note: Other services could similarly be swapped for their interfaces, but this has been left out of scope and should be addressed in a separate issue.
| Comment | File | Size | Author |
|---|---|---|---|
| logout-redirect-ModuleHandlerInterface-fix.patch | 1.33 KB | manu manu |
Comments
Comment #2
akashkumar07 commentedHi @manu-manu,
We also need to update the @var path for $moduleHandler
Rest changes look good.
If you want, i will be happy to create an MR for this issue fix.
Thanks!