Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | ||
3 | /* | |
4 | +--------------------------------------------------------------------+ | |
232624b1 | 5 | | CiviCRM version 4.4 | |
6a488035 TO |
6 | +--------------------------------------------------------------------+ |
7 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
8 | +--------------------------------------------------------------------+ | |
9 | | This file is a part of CiviCRM. | | |
10 | | | | |
11 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
12 | | under the terms of the GNU Affero General Public License | | |
13 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
14 | | | | |
15 | | CiviCRM is distributed in the hope that it will be useful, but | | |
16 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
17 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
18 | | See the GNU Affero General Public License for more details. | | |
19 | | | | |
20 | | You should have received a copy of the GNU Affero General Public | | |
21 | | License and the CiviCRM Licensing Exception along | | |
22 | | with this program; if not, contact CiviCRM LLC | | |
23 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
24 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
25 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
26 | +--------------------------------------------------------------------+ | |
27 | */ | |
28 | ||
29 | /** | |
30 | * | |
31 | * @package CiviCRM_Hook | |
32 | * @copyright CiviCRM LLC (c) 2004-2013 | |
33 | * $Id: $ | |
34 | * | |
35 | */ | |
36 | class CRM_Utils_Hook_Drupal extends CRM_Utils_Hook { | |
37 | ||
38 | /** | |
39 | * @var bool | |
40 | */ | |
41 | private $isBuilt = FALSE; | |
42 | ||
43 | /** | |
44 | * @var array(string) | |
45 | */ | |
46 | private $allModules = NULL; | |
47 | ||
48 | /** | |
49 | * @var array(string) | |
50 | */ | |
51 | private $civiModules = NULL; | |
52 | ||
53 | /** | |
54 | * @var array(string) | |
55 | */ | |
56 | private $drupalModules = NULL; | |
57 | ||
58 | function invoke($numParams, | |
87dab4a4 | 59 | &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, |
a038b933 | 60 | $fnSuffix |
6a488035 TO |
61 | ) { |
62 | ||
63 | $this->buildModuleList(); | |
64 | ||
65 | return $this->runHooks($this->allModules, $fnSuffix, | |
87dab4a4 | 66 | $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6 |
6a488035 TO |
67 | ); |
68 | } | |
69 | ||
6a488035 TO |
70 | /** |
71 | * Build the list of modules to be processed for hooks. | |
72 | */ | |
73 | function buildModuleList() { | |
74 | if ($this->isBuilt === FALSE) { | |
75 | if ($this->drupalModules === NULL) { | |
76 | if (function_exists('module_list')) { | |
77 | // copied from user_module_invoke | |
78 | $this->drupalModules = module_list(); | |
79 | } | |
80 | } | |
81 | ||
82 | if ($this->civiModules === NULL) { | |
83 | $this->civiModules = array(); | |
84 | $this->requireCiviModules($this->civiModules); | |
85 | } | |
86 | ||
eb8de3d8 | 87 | // we should add civicrm's module's just after main civicrm drupal module |
92623713 | 88 | // Note: Assume that drupalModules and civiModules may each be array() or NULL |
4636d4fd DL |
89 | if ($this->drupalModules !== NULL) { |
90 | foreach ($this->drupalModules as $moduleName) { | |
91 | $this->allModules[$moduleName] = $moduleName; | |
a038b933 | 92 | if ($moduleName == 'civicrm') { |
4636d4fd | 93 | if (!empty($this->civiModules)) { |
a038b933 | 94 | foreach ($this->civiModules as $civiModuleName) { |
4636d4fd DL |
95 | $this->allModules[$civiModuleName] = $civiModuleName; |
96 | } | |
eb8de3d8 KJ |
97 | } |
98 | } | |
99 | } | |
a038b933 TO |
100 | } |
101 | else { | |
92623713 | 102 | $this->allModules = (array) $this->civiModules; |
eb8de3d8 KJ |
103 | } |
104 | ||
6a488035 TO |
105 | if ($this->drupalModules !== NULL && $this->civiModules !== NULL) { |
106 | // both CRM and CMS have bootstrapped, so this is the final list | |
107 | $this->isBuilt = TRUE; | |
108 | } | |
109 | } | |
110 | } | |
111 | ||
112 | } |