Commit bf9587f5 authored by mattwire's avatar mattwire
Browse files

load CRM.payment via coreResourceList so it is added everywhere CiviCRM is...

load CRM.payment via coreResourceList so it is added everywhere CiviCRM is loaded (eg. drupal_webform etc)
parent 2f7c399a
......@@ -27,7 +27,7 @@ function mjwshared_civicrm_config(&$config) {
// 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);
Civi::dispatcher()->addListener('hook_civicrm_coreResourceList', 'mjwshared_symfony_civicrm_coreResourceList', 1000);
}
/**
......@@ -153,20 +153,21 @@ function mjwshared_civicrm_entityTypes(&$entityTypes) {
}
/**
* This hook is invoked when the 'confirm register' and 'thank you' form is rendered
* Implements hook_civicrm_coreResourceList().
*/
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',
]
), -2000, $region);
function mjwshared_symfony_civicrm_coreResourceList($event, $hook) {
if ($event->region === 'html-header') {
// 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.
\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',
]
), -2000, $event->region);
}
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment