Commit | Line | Data |
---|---|---|
f0a7a0c9 EM |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
f0a7a0c9 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
f0a7a0c9 EM |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
f0a7a0c9 EM |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
fa938177 | 31 | * @copyright CiviCRM LLC (c) 2004-2016 |
f0a7a0c9 EM |
32 | */ |
33 | class CRM_Utils_Hook_DrupalBase extends CRM_Utils_Hook { | |
34 | ||
35 | /** | |
36 | * @var bool | |
37 | */ | |
38 | private $isBuilt = FALSE; | |
39 | ||
40 | /** | |
41 | * @var array(string) | |
42 | */ | |
43 | private $allModules = NULL; | |
44 | ||
45 | /** | |
46 | * @var array(string) | |
47 | */ | |
48 | private $civiModules = NULL; | |
49 | ||
50 | /** | |
51 | * @var array(string) | |
52 | */ | |
53 | private $drupalModules = NULL; | |
54 | ||
55 | /** | |
77b97be7 | 56 | * @see CRM_Utils_Hook::invoke() |
f0a7a0c9 | 57 | * |
77855840 TO |
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. | |
77b97be7 | 70 | * @param mixed $arg6 |
77855840 TO |
71 | * @param string $fnSuffix |
72 | * Function suffix, this is effectively the hook name. | |
77b97be7 | 73 | * |
4a2db77c | 74 | * @return array|bool |
f0a7a0c9 | 75 | */ |
2da40d21 | 76 | public function invoke( |
a3e55d9c | 77 | $numParams, |
f0a7a0c9 EM |
78 | &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, |
79 | $fnSuffix) { | |
80 | ||
81 | $this->buildModuleList(); | |
82 | ||
83 | return $this->runHooks($this->allModules, $fnSuffix, | |
84 | $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6 | |
85 | ); | |
86 | } | |
87 | ||
88 | /** | |
89 | * Build the list of modules to be processed for hooks. | |
90 | */ | |
00be9182 | 91 | public function buildModuleList() { |
f0a7a0c9 EM |
92 | if ($this->isBuilt === FALSE) { |
93 | if ($this->drupalModules === NULL) { | |
94 | if (function_exists('module_list')) { | |
95 | // copied from user_module_invoke | |
96 | $this->drupalModules = module_list(); | |
97 | } | |
98 | } | |
99 | ||
100 | if ($this->civiModules === NULL) { | |
101 | $this->civiModules = array(); | |
102 | $this->requireCiviModules($this->civiModules); | |
103 | } | |
104 | ||
1a058091 KM |
105 | // CRM-12370 |
106 | // we should add civicrm's module's just after main civicrm drupal module | |
107 | // Note: Assume that drupalModules and civiModules may each be array() or NULL | |
108 | if ($this->drupalModules !== NULL) { | |
109 | foreach ($this->drupalModules as $moduleName) { | |
110 | $this->allModules[$moduleName] = $moduleName; | |
111 | if ($moduleName == 'civicrm') { | |
112 | if (!empty($this->civiModules)) { | |
113 | foreach ($this->civiModules as $civiModuleName) { | |
114 | $this->allModules[$civiModuleName] = $civiModuleName; | |
115 | } | |
116 | } | |
117 | } | |
118 | } | |
119 | } | |
120 | else { | |
121 | $this->allModules = (array) $this->civiModules; | |
122 | } | |
123 | ||
f0a7a0c9 EM |
124 | if ($this->drupalModules !== NULL && $this->civiModules !== NULL) { |
125 | // both CRM and CMS have bootstrapped, so this is the final list | |
126 | $this->isBuilt = TRUE; | |
127 | } | |
128 | } | |
129 | } | |
96025800 | 130 | |
77b97be7 | 131 | } |