Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Use events for CMS resource loading #14131

Merged
merged 1 commit into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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