3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2019
33 class CRM_Utils_Hook_DrupalBase
extends CRM_Utils_Hook
{
38 private $isBuilt = FALSE;
43 private $allModules = NULL;
48 private $civiModules = NULL;
53 private $drupalModules = NULL;
56 * @see CRM_Utils_Hook::invoke()
58 * @param int $numParams
59 * Number of parameters to pass to the hook.
60 * @param unknown $arg1
61 * Parameter to be passed to the hook.
62 * @param unknown $arg2
63 * Parameter to be passed to the hook.
64 * @param unknown $arg3
65 * Parameter to be passed to the hook.
66 * @param unknown $arg4
67 * Parameter to be passed to the hook.
68 * @param unknown $arg5
69 * Parameter to be passed to the hook.
71 * @param string $fnSuffix
72 * Function suffix, this is effectively the hook name.
76 public function invokeViaUF(
78 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
81 $this->buildModuleList();
83 return $this->runHooks($this->allModules
, $fnSuffix,
84 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
89 * Build the list of modules to be processed for hooks.
91 public function buildModuleList() {
92 if ($this->isBuilt
=== FALSE) {
93 if ($this->drupalModules
=== NULL) {
94 $this->drupalModules
= $this->getDrupalModules();
97 if ($this->civiModules
=== NULL) {
98 $this->civiModules
= array();
99 $this->requireCiviModules($this->civiModules
);
103 // we should add civicrm's module's just after main civicrm drupal module
104 // Note: Assume that drupalModules and civiModules may each be array() or NULL
105 if ($this->drupalModules
!== NULL) {
106 foreach ($this->drupalModules
as $moduleName) {
107 $this->allModules
[$moduleName] = $moduleName;
108 if ($moduleName == 'civicrm') {
109 if (!empty($this->civiModules
)) {
110 foreach ($this->civiModules
as $civiModuleName) {
111 $this->allModules
[$civiModuleName] = $civiModuleName;
118 $this->allModules
= (array) $this->civiModules
;
121 if ($this->drupalModules
!== NULL && $this->civiModules
!== NULL) {
122 // both CRM and CMS have bootstrapped, so this is the final list
123 $this->isBuilt
= TRUE;
129 * Gets modules installed on the Drupal site.
132 * The machine names of the modules installed in Drupal, or NULL if unable
133 * to determine the modules.
135 protected function getDrupalModules() {
136 if (function_exists('module_list')) {
137 // copied from user_module_invoke
138 return module_list();