From: Tim Otten Date: Sun, 23 Aug 2020 01:00:20 +0000 (-0700) Subject: CRM_Core_Resources - Move addCoreStyles to 'coreStyles' bundle X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5526ab4dd0aa9b7da984545842e9c1aea1d68303;p=civicrm-core.git CRM_Core_Resources - Move addCoreStyles to 'coreStyles' bundle --- diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 3ac2b72e88..15905c46c9 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -63,15 +63,6 @@ class CRM_Core_Resources { */ protected $addedCoreResources = []; - /** - * Added core styles. - * - * Format is ($regionName => bool). - * - * @var array - */ - protected $addedCoreStyles = []; - /** * Added settings. * @@ -616,9 +607,6 @@ class CRM_Core_Resources { /** * This will add CiviCRM's standard CSS * - * TODO: Separate the functional code (like addStyle/addScript) from the policy code - * (like addCoreResources/addCoreStyles). - * * @param string $region * @return CRM_Core_Resources */ @@ -630,21 +618,7 @@ class CRM_Core_Resources { // it appears that all callers use 'html-header' (either implicitly or explicitly). throw new \CRM_Core_Exception("Error: addCoreResources only supports html-header"); } - if (!isset($this->addedCoreStyles[$region])) { - $this->addedCoreStyles[$region] = TRUE; - - // Load custom or core css - $config = CRM_Core_Config::singleton(); - if (!empty($config->customCSSURL)) { - $customCSSURL = $this->addCacheCode($config->customCSSURL); - $this->addStyleUrl($customCSSURL, 99, $region); - } - if (!Civi::settings()->get('disable_core_css')) { - $this->addStyleFile('civicrm', 'css/civicrm.css', -99, $region); - } - // crm-i.css added ahead of other styles so it can be overridden by FA. - $this->addStyleFile('civicrm', 'css/crm-i.css', -101, $region); - } + $this->addBundle('coreStyles'); return $this; } diff --git a/CRM/Core/Resources/Common.php b/CRM/Core/Resources/Common.php index 008b60a5af..3159c08dce 100644 --- a/CRM/Core/Resources/Common.php +++ b/CRM/Core/Resources/Common.php @@ -26,7 +26,19 @@ class CRM_Core_Resources_Common { */ public static function createStyleBundle($name) { $bundle = new CRM_Core_Resources_Bundle($name); - // TODO + + // Load custom or core css + $config = CRM_Core_Config::singleton(); + if (!empty($config->customCSSURL)) { + $customCSSURL = Civi::resources()->addCacheCode($config->customCSSURL); + $bundle->addStyleUrl($customCSSURL, 99); + } + if (!Civi::settings()->get('disable_core_css')) { + $bundle->addStyleFile('civicrm', 'css/civicrm.css', -99); + } + // crm-i.css added ahead of other styles so it can be overridden by FA. + $bundle->addStyleFile('civicrm', 'css/crm-i.css', -101); + CRM_Utils_Hook::alterBundle($bundle); self::useRegion($bundle, self::REGION); return $bundle;