From 39299773df59bf28ea05c752e8a8e69bb68b2a31 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 7 Mar 2013 03:28:28 -0500 Subject: [PATCH] CRM-11925 - CRM_Utils_Hook - Remove moduleImplements. The Drupal implementation is good, but we don't need the functionality, and it's a bit of a liability because the design isn't portable to Joomla. Keeping it might encourage others to write unportable hook code. However, if we find that we do need the functionality, then we should use this code as a starting point. (Aside: For a non-Drupal example, the WordPress implementation is better than the Joomla implementation. The WP version looks like it would still work with Civi ext-modules.) --- CRM/Utils/Hook.php | 24 ------------------------ CRM/Utils/Hook/Drupal.php | 19 ------------------- CRM/Utils/Hook/Drupal6.php | 19 ------------------- CRM/Utils/Hook/Joomla.php | 8 -------- CRM/Utils/Hook/Soap.php | 11 ----------- CRM/Utils/Hook/UnitTests.php | 11 ----------- CRM/Utils/Hook/WordPress.php | 4 ---- 7 files changed, 96 deletions(-) diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 6881d068ff..b318ac02a3 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -91,12 +91,6 @@ abstract class CRM_Utils_Hook { $fnSuffix ); - /** - * Get a list of modules implementing the given hook. - * @return Array of module names. - */ - abstract function moduleImplements($hookName); - function commonInvoke($numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, $fnSuffix, $fnPrefix @@ -132,24 +126,6 @@ abstract class CRM_Utils_Hook { } } - /** - * Get a list of modules implementing the given hook. - * @return Array of module names. - */ - function commonModuleImplements($fnSuffix, $fnPrefix) { - $return = array(); - - $this->commonBuildModuleList($fnPrefix); - - foreach ($this->commonCiviModules as $module) { - $fnName = "{$module}_{$fnSuffix}"; - if (function_exists($fnName)) { - $return[] = $module; - } - } - return $return; - } - function runHooks(&$civiModules, $fnSuffix, $numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5 ) { diff --git a/CRM/Utils/Hook/Drupal.php b/CRM/Utils/Hook/Drupal.php index 99a231c4a4..b998aeb71e 100644 --- a/CRM/Utils/Hook/Drupal.php +++ b/CRM/Utils/Hook/Drupal.php @@ -67,25 +67,6 @@ class CRM_Utils_Hook_Drupal extends CRM_Utils_Hook { ); } - /** - * Get a list of modules implementing the given hook. - * @return Array of module names. - */ - function moduleImplements($hook_name) { - $return = array(); - - $this->buildModuleList(); - - // For each module, check if it defines a hook implementation. - foreach ($this->allModules as $module) { - $fnName = "{$module}_{$hook_name}"; - if (function_exists($fnName)) { - $return[] = $module; - } - } - return $return; - } - /** * Build the list of modules to be processed for hooks. */ diff --git a/CRM/Utils/Hook/Drupal6.php b/CRM/Utils/Hook/Drupal6.php index 31d3db89bd..f4a8a85445 100644 --- a/CRM/Utils/Hook/Drupal6.php +++ b/CRM/Utils/Hook/Drupal6.php @@ -67,25 +67,6 @@ class CRM_Utils_Hook_Drupal6 extends CRM_Utils_Hook { ); } - /** - * Get a list of modules implementing the given hook. - * @return Array of module names. - */ - function moduleImplements($hook_name) { - $return = array(); - - $this->buildModuleList(); - - // For each module, check if it defines a hook implementation. - foreach ($this->allModules as $module) { - $fnName = "{$module}_{$hook_name}"; - if (function_exists($fnName)) { - $return[] = $module; - } - } - return $return; - } - /** * Build the list of modules to be processed for hooks. */ diff --git a/CRM/Utils/Hook/Joomla.php b/CRM/Utils/Hook/Joomla.php index f8d8d84aa6..04ad66536c 100644 --- a/CRM/Utils/Hook/Joomla.php +++ b/CRM/Utils/Hook/Joomla.php @@ -81,13 +81,5 @@ class CRM_Utils_Hook_Joomla extends CRM_Utils_Hook { return $result; } } - - /** - * Get a list of modules implementing the given hook. Does nothing in Joomla. - * @return Array of module names. - */ - function moduleImplements($fnSuffix) { - return array(); - } } diff --git a/CRM/Utils/Hook/Soap.php b/CRM/Utils/Hook/Soap.php index 95b6fa2986..424afe22a7 100644 --- a/CRM/Utils/Hook/Soap.php +++ b/CRM/Utils/Hook/Soap.php @@ -41,16 +41,5 @@ class CRM_Utils_Hook_Soap extends CRM_Utils_Hook { // suppress all hok calls during soap return; } - - /** - * Get a list of modules implementing the given hook. - * - * Does nothing in Soap. - * - * @return Array of module names. - */ - function moduleImplements($fnSuffix) { - return; - } } diff --git a/CRM/Utils/Hook/UnitTests.php b/CRM/Utils/Hook/UnitTests.php index e4610308c6..6004cff919 100644 --- a/CRM/Utils/Hook/UnitTests.php +++ b/CRM/Utils/Hook/UnitTests.php @@ -70,16 +70,5 @@ class CRM_Utils_Hook_UnitTests extends CRM_Utils_Hook { call_user_func_array($this->adhocHooks[$fnSuffix], $params ); } } - - /** - * Get a list of modules implementing the given hook. - * - * Does nothing in UnitTests. - * - * @return Array of module names. - */ - function moduleImplements($fnSuffix) { - return; - } } diff --git a/CRM/Utils/Hook/WordPress.php b/CRM/Utils/Hook/WordPress.php index f86094f443..f7c98a029e 100644 --- a/CRM/Utils/Hook/WordPress.php +++ b/CRM/Utils/Hook/WordPress.php @@ -42,9 +42,5 @@ class CRM_Utils_Hook_WordPress extends CRM_Utils_Hook { $fnSuffix, 'wordpress' ); } - - function moduleImplements($fnSuffix) { - return $this->commonModuleImplements($fnSuffix, 'wordpress'); - } } -- 2.25.1