Skip to content

Commit

Permalink
Merge pull request #14131 from colemanw/resourceList
Browse files Browse the repository at this point in the history
[REF] Use events for CMS resource loading
  • Loading branch information
totten authored Apr 26, 2019
2 parents 4c5fa0a + 303017a commit b632d5e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
3 changes: 0 additions & 3 deletions CRM/Utils/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -2386,9 +2386,6 @@ public static function batchItems(&$results, &$items) {
* @param string $region
*/
public static function coreResourceList(&$list, $region) {
// First allow the cms integration to add to the list
CRM_Core_Config::singleton()->userSystem->appendCoreResources($list);

self::singleton()->invoke(['list', 'region'], $list, $region,
self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
'civicrm_coreResourceList'
Expand Down
1 change: 1 addition & 0 deletions CRM/Utils/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
* @method static int getLoggedInUfID() Get current logged in user id.
* @method static setHttpHeader(string $name, string $value) Set http header.
* @method static array synchronizeUsers() Create CRM contacts for all existing CMS users.
* @method static appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) Callback for hook_civicrm_coreResourceList.
*/
class CRM_Utils_System {

Expand Down
8 changes: 4 additions & 4 deletions CRM/Utils/System/Backdrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -1042,11 +1042,11 @@ private function parseBackdropSiteNameFromRequest($flagFile = '') {
/**
* Append Backdrop CSS and JS to coreResourcesList.
*
* @param array $list
* @param \Civi\Core\Event\GenericHookEvent $e
*/
public function appendCoreResources(&$list) {
$list[] = 'css/backdrop.css';
$list[] = 'js/crm.backdrop.js';
public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) {
$e->list[] = 'css/backdrop.css';
$e->list[] = 'js/crm.backdrop.js';
}

}
4 changes: 2 additions & 2 deletions CRM/Utils/System/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -914,9 +914,9 @@ public function logger($message) {
/**
* Append to coreResourcesList.
*
* @param array $list
* @param \Civi\Core\Event\GenericHookEvent $e
*/
public function appendCoreResources(&$list) {
public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) {
}

/**
Expand Down
6 changes: 3 additions & 3 deletions CRM/Utils/System/Drupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,10 @@ public function getCurrentLanguage() {
/**
* Append Drupal8 js to coreResourcesList.
*
* @param array $list
* @param \Civi\Core\Event\GenericHookEvent $e
*/
public function appendCoreResources(&$list) {
$list[] = 'js/crm.drupal8.js';
public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) {
$e->list[] = 'js/crm.drupal8.js';
}

}
6 changes: 3 additions & 3 deletions CRM/Utils/System/WordPress.php
Original file line number Diff line number Diff line change
Expand Up @@ -801,10 +801,10 @@ public function getUserRecordUrl($contactID) {
/**
* Append WP js to coreResourcesList.
*
* @param array $list
* @param \Civi\Core\Event\GenericHookEvent $e
*/
public function appendCoreResources(&$list) {
$list[] = 'js/crm.wordpress.js';
public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) {
$e->list[] = 'js/crm.wordpress.js';
}

/**
Expand Down
1 change: 1 addition & 0 deletions Civi/Core/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ public function createEventDispatcher($container) {
$dispatcher->addListener('hook_civicrm_buildAsset', ['\CRM_Utils_VisualBundle', 'buildAssetJs']);
$dispatcher->addListener('hook_civicrm_buildAsset', ['\CRM_Utils_VisualBundle', 'buildAssetCss']);
$dispatcher->addListener('hook_civicrm_buildAsset', ['\CRM_Core_Resources', 'renderMenubarStylesheet']);
$dispatcher->addListener('hook_civicrm_coreResourceList', ['\CRM_Utils_System', 'appendCoreResources']);
$dispatcher->addListener('civi.dao.postInsert', ['\CRM_Core_BAO_RecurringEntity', 'triggerInsert']);
$dispatcher->addListener('civi.dao.postUpdate', ['\CRM_Core_BAO_RecurringEntity', 'triggerUpdate']);
$dispatcher->addListener('civi.dao.postDelete', ['\CRM_Core_BAO_RecurringEntity', 'triggerDelete']);
Expand Down

0 comments on commit b632d5e

Please sign in to comment.