From 996f54f1153c0187f25661c1916f0d577e66fa55 Mon Sep 17 00:00:00 2001 From: Aidan Saunders Date: Wed, 12 May 2021 20:46:46 +0100 Subject: [PATCH] Give the custom css file a 'name' to make it easier to manipulate in hook_civicrm_alterBundle() --- CRM/Core/Resources/Common.php | 2 +- tests/phpunit/CRM/Core/Resources/BundleTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Resources/Common.php b/CRM/Core/Resources/Common.php index 5f11d0314f..92fff3159a 100644 --- a/CRM/Core/Resources/Common.php +++ b/CRM/Core/Resources/Common.php @@ -97,7 +97,7 @@ class CRM_Core_Resources_Common { $config = CRM_Core_Config::singleton(); if (!empty($config->customCSSURL)) { $customCSSURL = Civi::resources()->addCacheCode($config->customCSSURL); - $bundle->addStyleUrl($customCSSURL, 99); + $bundle->addStyleUrl($customCSSURL, ['weight' => 99, 'name' => 'civicrm:css/custom.css']); } if (!Civi::settings()->get('disable_core_css')) { $bundle->addStyleFile('civicrm', 'css/civicrm.css', -99); diff --git a/tests/phpunit/CRM/Core/Resources/BundleTest.php b/tests/phpunit/CRM/Core/Resources/BundleTest.php index 08490b9794..b456b86657 100644 --- a/tests/phpunit/CRM/Core/Resources/BundleTest.php +++ b/tests/phpunit/CRM/Core/Resources/BundleTest.php @@ -72,4 +72,16 @@ class CRM_Core_Resources_BundleTest extends CiviUnitTestCase { $this->assertEquals('page-header', $bundle->get('cheese')['region']); } + /** + * Test creation of coreStyles bundle + */ + public function testCoreStylesBundle() { + $config = CRM_Core_Config::singleton(); + $config->customCSSURL = "http://example.com/css/custom.css"; + $bundle = CRM_Core_Resources_Common::createStyleBundle('coreStyles'); + $this->assertEquals('civicrm:css/civicrm.css', $bundle->get('civicrm:css/civicrm.css')['name']); + $this->assertEquals('civicrm:css/crm-i.css', $bundle->get('civicrm:css/crm-i.css')['name']); + $this->assertEquals('civicrm:css/custom.css', $bundle->get('civicrm:css/custom.css')['name']); + } + } -- 2.25.1