From: Tim Otten Date: Tue, 7 Mar 2017 22:13:31 +0000 (-0800) Subject: CRM-19813 - CRM_Utils_Hook::invoke() - Use dispatcher when possible X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e24a07e66b4bed78f5bd8ea92781fe07f8880825;p=civicrm-core.git CRM-19813 - CRM_Utils_Hook::invoke() - Use dispatcher when possible --- 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); + } } /**