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 +--------------------------------------------------------------------+
14 * @package CiviCRM_Hook
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Utils_Hook_Joomla
extends CRM_Utils_Hook
{
21 * @param int $numParams
22 * Number of parameters to pass to the hook.
24 * Parameter to be passed to the hook.
26 * Parameter to be passed to the hook.
28 * Parameter to be passed to the hook.
30 * Parameter to be passed to the hook.
32 * Parameter to be passed to the hook.
34 * Parameter to be passed to the hook.
35 * @param string $fnSuffix
36 * Function suffix, this is effectively the hook name.
42 * @param int $numParams
49 * @param string $fnSuffix
53 public function invokeViaUF(
55 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
58 // ensure that we are running in a joomla context
59 // we've not yet figured out how to bootstrap joomla, so we should
60 // not execute hooks if joomla is not loaded
61 if (defined('_JEXEC')) {
62 //Invoke the Joomla plugin system to observe to civicrm events.
63 jimport('joomla.plugin.helper');
64 jimport('cms.plugin.helper');
65 JPluginHelper
::importPlugin('civicrm');
67 // get app based on cli or web
68 if (PHP_SAPI
!= 'cli') {
69 $app = JFactory
::getApplication('administrator');
72 // condition on Joomla version
73 if (version_compare(JVERSION
, '3.0', 'lt')) {
74 $app = JCli
::getInstance();
77 $app = JApplicationCli
::getInstance();
81 $result = $app->triggerEvent($fnSuffix, array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6));
83 $moduleResult = $this->commonInvoke($numParams,
84 $arg1, $arg2, $arg3, $arg4, $arg5, $arg6,
86 if (!empty($moduleResult) && is_array($moduleResult)) {
88 $result = $moduleResult;
91 if (is_array($moduleResult)) {
92 $result = array_merge($result, $moduleResult);
97 if (!empty($result)) {
98 // collapse result returned from hooks
101 foreach ($result as $res) {
102 if (!is_array($res)) {
105 $finalResult = array_merge($finalResult, $res);
107 $result = $finalResult;
112 // CRM-20904: We should still call Civi extension hooks even if Joomla isn't online yet.
113 return $this->commonInvoke($numParams,
114 $arg1, $arg2, $arg3, $arg4, $arg5, $arg6,
115 $fnSuffix, 'joomla');