From 40f6491b193b39753faa153d9b49a3eb113e52e8 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 8 Apr 2019 16:20:36 -0700 Subject: [PATCH] Pass menubar preference as a param. Simplify cache mechanics. (#8) Ex: If an admin uses an API call (CLI/REST) to change the menubar color, then they don't need to follow-up with a cache-clear. The new setting just goes live. Ex: If a customization (via `civicrm.settings.php` or via extension) decides on the color scheme programmatically (e.g. per-domain or per-role or per-user-preference), then they don't need to clear cache. Multiple color schemes can coexist. --- CRM/Admin/Form/Preferences/Display.php | 2 -- CRM/Core/Resources.php | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index 2ed8583f4bb4..c6f5930ba18f 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -106,8 +106,6 @@ public function postProcess() { $this->postProcessCommon(); - \Civi::service('asset_builder')->clear(); - // If "Configure CKEditor" button was clicked if (!empty($this->_params['ckeditor_config'])) { // Suppress the "Saved" status message and redirect to the CKEditor Config page diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 921fba8dbbba..9d9a8a86134f 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -765,7 +765,9 @@ public function coreResourceList($region) { $items[] = 'bower_components/smartmenus/dist/jquery.smartmenus.min.js'; $items[] = 'bower_components/smartmenus/dist/addons/keyboard/jquery.smartmenus.keyboard.min.js'; $items[] = 'js/crm.menubar.js'; - $items[] = Civi::service('asset_builder')->getUrl('crm-menubar.css'); + $items[] = Civi::service('asset_builder')->getUrl('crm-menubar.css', [ + 'color' => Civi::settings()->get('menubar_color'), + ]); $items[] = [ 'menubar' => [ 'position' => $position, @@ -844,7 +846,7 @@ public static function renderMenubarStylesheet(GenericHookEvent $e) { foreach ($items as $item) { $e->content .= file_get_contents(self::singleton()->getPath('civicrm', $item)); } - $color = Civi::settings()->get('menubar_color'); + $color = $e->params['color']; if (!CRM_Utils_Rule::color($color)) { $color = Civi::settings()->getDefault('menubar_color'); }