Skip to content

Instantly share code, notes, and snippets.

@michaelmcandrew
Created June 13, 2018 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelmcandrew/b050e6522dcb1430ea8140fc5c202493 to your computer and use it in GitHub Desktop.
Save michaelmcandrew/b050e6522dcb1430ea8140fc5c202493 to your computer and use it in GitHub Desktop.
<?php
function chatbot_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
var_dump('calling chatbot_civicrm_alterSettingsFolders');
_chatbot_civix_civicrm_alterSettingsFolders($metaDataFolders);
}

The output of testScript.sh shows that chatbot_civicrm_alterSettingsFolders is being called but for some reason, the folder is not always added to $metaDataFolders.

Next step is to dig into \Civi::dispatcher()->dispatch('hook_' . $fnSuffix, $event);

I have had a look at Civi\Core\Event\GenericHookEvent but am struggling to work outwhere the dispatch method is (would be nice to step through with a debugger but do not have one configured).

<?php
public function invoke(
$names,
&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
$fnSuffix
) {
if (is_array($names) && !defined('CIVICRM_FORCE_LEGACY_HOOK') && \Civi\Core\Container::isContainerBooted()) {
$event = \Civi\Core\Event\GenericHookEvent::createOrdered(
$names,
array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6)
);
\Civi::dispatcher()->dispatch('hook_' . $fnSuffix, $event);
if ($names[0] == 'settingsFolders') { //added some debugging code
var_dump($arg1);
}
return $event->getReturnValues();
}
else {
$count = is_array($names) ? count($names) : $names;
return $this->invokeViaUF($count, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $fnSuffix);
}
}
# Output of
cv ext:enable angularex
cv ext:uninstall angularex
# is as follows
Enabling extension "org.civicrm.angularex"
/buildkit/build/chatbot/sites/all/modules/civicrm/tools/extensions/civicrm-chatbot/chatbot.php:154:
string(44) "calling chatbot_civicrm_alterSettingsFolders"
/buildkit/build/chatbot/sites/all/modules/civicrm/CRM/Utils/Hook.php:166:
array(2) {
[0] =>
string(59) "/buildkit/build/chatbot/sites/all/modules/civicrm//settings"
[1] =>
string(91) "/buildkit/build/chatbot/sites/all/modules/civicrm/tools/extensions/civicrm-chatbot/settings"
}
Uninstalling extension "org.civicrm.angularex"
/buildkit/build/chatbot/sites/all/modules/civicrm/tools/extensions/civicrm-chatbot/chatbot.php:154:
string(44) "calling chatbot_civicrm_alterSettingsFolders"
/buildkit/build/chatbot/sites/all/modules/civicrm/CRM/Utils/Hook.php:166:
array(2) {
[0] =>
string(59) "/buildkit/build/chatbot/sites/all/modules/civicrm//settings"
[1] =>
string(91) "/buildkit/build/chatbot/sites/all/modules/civicrm/tools/extensions/civicrm-chatbot/settings"
}
/buildkit/build/chatbot/sites/all/modules/civicrm/tools/extensions/civicrm-chatbot/chatbot.php:154:
string(44) "calling chatbot_civicrm_alterSettingsFolders"
/buildkit/build/chatbot/sites/all/modules/civicrm/CRM/Utils/Hook.php:166:
array(1) {
[0] =>
string(59) "/buildkit/build/chatbot/sites/all/modules/civicrm//settings"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment