if (method_exists($this->moduleHandler, 'invokeAllWIth')) {
$this->moduleHandler->invokeAllWith('mail', function (callable $hook, string $module) use (&$list) {
$list[$module] = $this->moduleHandler->getName($module);
});
}
else {
foreach ($this->moduleHandler->getImplementations('mail') as $module) {
$list[$module] = $this->moduleHandler->getName($module);
}
}
Let's see if the latter can not error. It currently does