Type mismatch for moduleHandler service in dependency injection in AgentHelper.php with hook_event_dispatcher module
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3528135. --> Reported by: [sharma.amitt16](https://www.drupal.org/user/2629679) Related to !137 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>If the hook_event_dispatcher module is enabled in Drupal (10.3.10), it is throwing an error as given below</p> <p><code>TypeError: Drupal\ai_agents\Service\AgentHelper::__construct(): Argument #2 ($moduleHandler) must be of type Drupal\Core\Extension\ModuleHandler, Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler given, called in /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 261 in Drupal\ai_agents\Service\AgentHelper-&gt;__construct() (line 98 of modules/contrib/ai_agents/src/Service/AgentHelper.php).</code></p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <ul> <li>Removed the strict type from AgentHelper.php constructor</li> <li>Added a service alias in ai_agent.services.yml</li> <li>Updated the arguments for ai_agents.agent_helper in services.yml to use @ai_agent.module_handler_adapter as second argument. </li> </ul> <p>NOTE: Please use this patch carefully if you don't have dependency on hook_event_dispatcher</p>
issue