From 303017a1f28854832ea4b6a34b0960bb9140e0e3 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 25 Apr 2019 10:41:49 -0400 Subject: [PATCH] Use events for CMS resource loading --- CRM/Utils/Hook.php | 3 --- CRM/Utils/System.php | 1 + CRM/Utils/System/Backdrop.php | 8 ++++---- CRM/Utils/System/Base.php | 4 ++-- CRM/Utils/System/Drupal8.php | 6 +++--- CRM/Utils/System/WordPress.php | 6 +++--- Civi/Core/Container.php | 1 + 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index a47f3076d7..024692ea3d 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -2386,9 +2386,6 @@ abstract class CRM_Utils_Hook { * @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' diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 0aa8fe3e67..6733d57f7e 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -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 { diff --git a/CRM/Utils/System/Backdrop.php b/CRM/Utils/System/Backdrop.php index 7a3589a250..9c22b6b86b 100644 --- a/CRM/Utils/System/Backdrop.php +++ b/CRM/Utils/System/Backdrop.php @@ -1042,11 +1042,11 @@ AND u.status = 1 /** * 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'; } } diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index bf6830d8e4..0ad46528d4 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -914,9 +914,9 @@ abstract class CRM_Utils_System_Base { /** * Append to coreResourcesList. * - * @param array $list + * @param \Civi\Core\Event\GenericHookEvent $e */ - public function appendCoreResources(&$list) { + public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) { } /** diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index d34007e547..e280a40ba7 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -667,10 +667,10 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { /** * 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'; } } diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index a188cff501..5beecc51ea 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -801,10 +801,10 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { /** * 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'; } /** diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index 201111773a..579ee3083e 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -321,6 +321,7 @@ class 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']); -- 2.25.1