From e24a07e66b4bed78f5bd8ea92781fe07f8880825 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 7 Mar 2017 14:13:31 -0800 Subject: [PATCH] CRM-19813 - CRM_Utils_Hook::invoke() - Use dispatcher when possible --- CRM/Utils/Hook.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 2636f45275..9446f30c84 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -156,8 +156,18 @@ abstract class CRM_Utils_Hook { &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix ) { - $count = is_array($names) ? count($names) : $names; - return $this->invokeViaUF($count, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $fnSuffix); + if (is_array($names) && !defined('CIVICRM_FORCE_LEGACY_HOOK')) { + $event = \Civi\Core\Event\GenericHookEvent::createOrdered( + $names, + array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6) + ); + \Civi::dispatcher()->dispatch('hook_' . $fnSuffix, $event); + return $event->getReturnValues(); + } + else { + $count = is_array($names) ? count($names) : $names; + return $this->invokeViaUF($count, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $fnSuffix); + } } /** -- 2.25.1