Skip to content

Commit

Permalink
LCH-7174: Fixing deprecation of module_handler service.
Browse files Browse the repository at this point in the history
  • Loading branch information
narendradesai committed Nov 19, 2024
1 parent 3a53438 commit 2e6d6b1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Command/PqCommands/ContentHubPqCodeCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,23 @@ protected function configure() {
*/
public function getHookImplementation(): array {
$hookImplementation = [];
/** @var \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler */
$moduleHandler = $this->drupalServiceFactory->getDrupalService('module_handler');
foreach (ContentHubAudit::V1_MODULE_HOOKS as $hook) {
if (!empty($moduleList = $moduleHandler->getImplementations($hook))) {
$hookImplementation[$hook] = $moduleList;
if (method_exists($moduleHandler, 'invokeAllWith')) {
$moduleHandler->invokeAllWith(
$hook,
function (callable $hook, string $module) use (&$implementations) {
if (!empty($module)) {
$implementations[$hook][] = $module;
}
}
);
}
else {
if (!empty($moduleList = $moduleHandler->getImplementations($hook))) {
$hookImplementation[$hook] = $moduleList;
}
}
}
return $hookImplementation;
Expand Down

0 comments on commit 2e6d6b1

Please sign in to comment.