From 2e6d6b125cd7eca7a24ef770281f985dea706c0a Mon Sep 17 00:00:00 2001 From: "narendra.desai" Date: Tue, 19 Nov 2024 11:49:14 +0530 Subject: [PATCH] LCH-7174: Fixing deprecation of module_handler service. --- .../PqCommands/ContentHubPqCodeCheck.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Command/PqCommands/ContentHubPqCodeCheck.php b/src/Command/PqCommands/ContentHubPqCodeCheck.php index 012753b..e4a9ce7 100644 --- a/src/Command/PqCommands/ContentHubPqCodeCheck.php +++ b/src/Command/PqCommands/ContentHubPqCodeCheck.php @@ -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;