3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Utils_Hook_DrupalBase
extends CRM_Utils_Hook
{
22 private $isBuilt = FALSE;
29 private $allModules = NULL;
36 private $civiModules = NULL;
43 private $drupalModules = NULL;
46 * @param int $numParams
47 * Number of parameters to pass to the hook.
49 * Parameter to be passed to the hook.
51 * Parameter to be passed to the hook.
53 * Parameter to be passed to the hook.
55 * Parameter to be passed to the hook.
57 * Parameter to be passed to the hook.
59 * @param string $fnSuffix
60 * Function suffix, this is effectively the hook name.
64 * @see CRM_Utils_Hook::invoke()
66 public function invokeViaUF(
68 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
71 $this->buildModuleList();
73 return $this->runHooks($this->allModules
, $fnSuffix,
74 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
79 * Build the list of modules to be processed for hooks.
81 public function buildModuleList() {
82 if ($this->isBuilt
=== FALSE) {
83 if ($this->drupalModules
=== NULL) {
84 $this->drupalModules
= $this->getDrupalModules();
87 if ($this->civiModules
=== NULL) {
88 $this->civiModules
= [];
89 $this->requireCiviModules($this->civiModules
);
93 // we should add civicrm's module's just after main civicrm drupal module
94 // Note: Assume that drupalModules and civiModules may each be array() or NULL
95 if ($this->drupalModules
!== NULL) {
96 foreach ($this->drupalModules
as $moduleName) {
97 $this->allModules
[$moduleName] = $moduleName;
98 if ($moduleName == 'civicrm') {
99 if (!empty($this->civiModules
)) {
100 foreach ($this->civiModules
as $civiModuleName) {
101 $this->allModules
[$civiModuleName] = $civiModuleName;
108 $this->allModules
= (array) $this->civiModules
;
111 if ($this->drupalModules
!== NULL && $this->civiModules
!== NULL) {
112 // both CRM and CMS have bootstrapped, so this is the final list
113 $this->isBuilt
= TRUE;
119 * Gets modules installed on the Drupal site.
122 * The machine names of the modules installed in Drupal, or NULL if unable
123 * to determine the modules.
125 protected function getDrupalModules() {
126 if (function_exists('module_list')) {
127 // copied from user_module_invoke
128 return module_list();