From: Tim Otten Date: Tue, 7 Mar 2017 22:06:10 +0000 (-0800) Subject: CRM-19813 - CRM_Utils_Hook_* - Rename invoke() to invokeViaUF() X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=354345c9a80296978d6938cd09fdde6e8f32cc1f;p=civicrm-core.git CRM-19813 - CRM_Utils_Hook_* - Rename invoke() to invokeViaUF() We're going to provide transitional wrapper function for `invoke()`, but we'll still need access to the original implementations. This renames the original implementations. --- diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 00b0bb7354..dec10d814a 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -101,7 +101,8 @@ abstract class CRM_Utils_Hook { } /** - * Invoke hooks. + * Invoke a hook through the UF/CMS hook system and the extension-hook + * system. * * @param int $numParams * Number of parameters to pass to the hook. @@ -122,12 +123,43 @@ abstract class CRM_Utils_Hook { * * @return mixed */ - public abstract function invoke( + public abstract function invokeViaUF( $numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix ); + /** + * Invoke a hook. + * + * This is a transitional adapter. It supports the legacy syntax + * but also accepts enough information to support Symfony Event + * dispatching. + * + * @param array|int $names + * (Recommended) Array of parameter names, in order. + * Using an array is recommended because it enables full + * event-broadcasting behaviors. + * (Legacy) Number of parameters to pass to the hook. + * This is provided for transitional purposes. + * @param mixed $arg1 + * @param mixed $arg2 + * @param mixed $arg3 + * @param mixed $arg4 + * @param mixed $arg5 + * @param mixed $arg6 + * @param mixed $fnSuffix + * @return mixed + */ + public function invoke( + $names, + &$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); + } + /** * @param array $numParams * @param $arg1 diff --git a/CRM/Utils/Hook/DrupalBase.php b/CRM/Utils/Hook/DrupalBase.php index f92a5ca369..2adce368b7 100644 --- a/CRM/Utils/Hook/DrupalBase.php +++ b/CRM/Utils/Hook/DrupalBase.php @@ -73,7 +73,7 @@ class CRM_Utils_Hook_DrupalBase extends CRM_Utils_Hook { * * @return array|bool */ - public function invoke( + public function invokeViaUF( $numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix) { diff --git a/CRM/Utils/Hook/Joomla.php b/CRM/Utils/Hook/Joomla.php index 3f683f3cc8..fd1793cb72 100644 --- a/CRM/Utils/Hook/Joomla.php +++ b/CRM/Utils/Hook/Joomla.php @@ -65,7 +65,7 @@ class CRM_Utils_Hook_Joomla extends CRM_Utils_Hook { * * @return mixed */ - public function invoke( + public function invokeViaUF( $numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix diff --git a/CRM/Utils/Hook/Soap.php b/CRM/Utils/Hook/Soap.php index 675d6f600f..685fd9ba30 100644 --- a/CRM/Utils/Hook/Soap.php +++ b/CRM/Utils/Hook/Soap.php @@ -65,7 +65,7 @@ class CRM_Utils_Hook_Soap extends CRM_Utils_Hook { * * @return mixed */ - public function invoke( + public function invokeViaUF( $numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix diff --git a/CRM/Utils/Hook/UnitTests.php b/CRM/Utils/Hook/UnitTests.php index 2061c30c49..14ef3fb6eb 100644 --- a/CRM/Utils/Hook/UnitTests.php +++ b/CRM/Utils/Hook/UnitTests.php @@ -94,7 +94,7 @@ class CRM_Utils_Hook_UnitTests extends CRM_Utils_Hook { * * @return mixed */ - public function invoke( + public function invokeViaUF( $numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix) { diff --git a/CRM/Utils/Hook/WordPress.php b/CRM/Utils/Hook/WordPress.php index 977a746c23..74cd81f890 100644 --- a/CRM/Utils/Hook/WordPress.php +++ b/CRM/Utils/Hook/WordPress.php @@ -83,7 +83,7 @@ class CRM_Utils_Hook_WordPress extends CRM_Utils_Hook { * * @return mixed */ - public function invoke( + public function invokeViaUF( $numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix