Skip to content

Commit

Permalink
CRM_Core_Resources - Move addCoreStyles to 'coreStyles' bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
totten authored and seamuslee001 committed Sep 3, 2020
1 parent b2d8361 commit 5526ab4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
28 changes: 1 addition & 27 deletions CRM/Core/Resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ class CRM_Core_Resources {
*/
protected $addedCoreResources = [];

/**
* Added core styles.
*
* Format is ($regionName => bool).
*
* @var array
*/
protected $addedCoreStyles = [];

/**
* Added settings.
*
Expand Down Expand Up @@ -616,9 +607,6 @@ public function addCoreResources($region = 'html-header') {
/**
* 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
*/
Expand All @@ -630,21 +618,7 @@ public function addCoreStyles($region = 'html-header') {
// 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;
}

Expand Down
14 changes: 13 additions & 1 deletion CRM/Core/Resources/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5526ab4

Please sign in to comment.