Skip to content
Snippets Groups Projects
Commit e2039573 authored by mattwire's avatar mattwire
Browse files

Load crm.payment.js early on

parent 37ab0f41
No related branches found
No related tags found
1 merge request!90.9
......@@ -23,9 +23,11 @@ function mjwshared_civicrm_config(&$config) {
if (isset(Civi::$statics[__FUNCTION__])) { return; }
Civi::$statics[__FUNCTION__] = 1;
// Add listeners for CiviCRM hooks that might need altering by other scripts
// Symfony hook priorities - see https://docs.civicrm.org/dev/en/latest/hooks/usage/symfony/#priorities
// Make sure this runs after everything else but before minifier
Civi::dispatcher()->addListener('hook_civicrm_buildAsset', 'mjwshared_symfony_civicrm_buildAsset', -990);
// This should run before (almost) anything else as we're loading shared libraries
Civi::dispatcher()->addListener('hook_civicrm_buildForm', 'mjwshared_symfony_civicrm_buildForm', 1000);
}
/**
......@@ -153,15 +155,18 @@ function mjwshared_civicrm_entityTypes(&$entityTypes) {
/**
* This hook is invoked when the 'confirm register' and 'thank you' form is rendered
*/
function mjwshared_civicrm_buildForm($formName, &$form) {
function mjwshared_symfony_civicrm_buildForm($event, $hook) {
// Load the CRM.payment library
// We want this library loaded early. Weights are negative earlier, positive later (opposite to symfony).
// CiviCRM "earliest" is -9999 we'll go with -2000 to load after CiviCRM core but before anything else.
$region = (CRM_Utils_Request::retrieveValue('is_drupal_webform', 'Boolean', FALSE)) ? 'billing-block' : 'page-header';
\Civi::resources()->addScriptUrl(\Civi::service('asset_builder')->getUrl(
'crm.payment.js',
[
'path' => \Civi::resources()->getPath(E::LONG_NAME, 'js/crm.payment.js'),
'mimetype' => 'application/javascript',
]
), 1000, 'billing-block');
), -2000, $region);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment