diff --git a/modules/backend/models/BrandSetting.php b/modules/backend/models/BrandSetting.php index 389f12d12..c03160af9 100644 --- a/modules/backend/models/BrandSetting.php +++ b/modules/backend/models/BrandSetting.php @@ -41,8 +41,11 @@ class BrandSetting extends Model public $attachOne = [ 'logo' => \System\Models\File::class ]; - - const CACHE_KEY = 'backend::brand.custom_css'; + + /** + * @var string The key to store rendered CSS in the cache under + */ + public $cacheKey = 'backend::brand.custom_css'; const PRIMARY_COLOR = '#34495e'; // Wet Asphalt const SECONDARY_COLOR = '#e67e22'; // Pumpkin @@ -79,7 +82,7 @@ class BrandSetting extends Model public function afterSave() { - Cache::forget(self::CACHE_KEY); + Cache::forget(self::instance()->cacheKey); } public static function getLogo() @@ -95,13 +98,14 @@ class BrandSetting extends Model public static function renderCss() { - if (Cache::has(self::CACHE_KEY)) { - return Cache::get(self::CACHE_KEY); + $cacheKey = self::instance()->cacheKey; + if (Cache::has($cacheKey)) { + return Cache::get($cacheKey); } try { $customCss = self::compileCss(); - Cache::forever(self::CACHE_KEY, $customCss); + Cache::forever($cacheKey, $customCss); } catch (Exception $ex) { $customCss = '/* ' . $ex->getMessage() . ' */'; diff --git a/modules/backend/models/EditorSetting.php b/modules/backend/models/EditorSetting.php index 9dc9d86ec..4fda96bcf 100644 --- a/modules/backend/models/EditorSetting.php +++ b/modules/backend/models/EditorSetting.php @@ -33,8 +33,11 @@ class EditorSetting extends Model * @var mixed Settings form field defitions */ public $settingsFields = 'fields.yaml'; - - const CACHE_KEY = 'backend::editor.custom_css'; + + /** + * @var string The key to store rendered CSS in the cache under + */ + public $cacheKey = 'backend::editor.custom_css'; protected $defaultHtmlAllowEmptyTags = 'textarea, a, iframe, object, video, style, script'; @@ -100,7 +103,7 @@ class EditorSetting extends Model public function afterSave() { - Cache::forget(self::CACHE_KEY); + Cache::forget(self::instance()->cacheKey); } protected function makeStylesForTable($arr) @@ -157,13 +160,14 @@ class EditorSetting extends Model public static function renderCss() { - if (Cache::has(self::CACHE_KEY)) { - return Cache::get(self::CACHE_KEY); + $cacheKey = self::instance()->cacheKey; + if (Cache::has($cacheKey)) { + return Cache::get($cacheKey); } try { $customCss = self::compileCss(); - Cache::forever(self::CACHE_KEY, $customCss); + Cache::forever($cacheKey, $customCss); } catch (Exception $ex) { $customCss = '/* ' . $ex->getMessage() . ' */'; diff --git a/modules/system/models/MailBrandSetting.php b/modules/system/models/MailBrandSetting.php index 9f2a075c5..528ce2641 100644 --- a/modules/system/models/MailBrandSetting.php +++ b/modules/system/models/MailBrandSetting.php @@ -35,8 +35,11 @@ class MailBrandSetting extends Model * @var mixed Settings form field defitions */ public $settingsFields = 'fields.yaml'; - - const CACHE_KEY = 'system::mailbrand.custom_css'; + + /** + * @var string The key to store rendered CSS in the cache under + */ + public $cacheKey = 'system::mailbrand.custom_css'; const WHITE_COLOR = '#fff'; const BODY_BG = '#f5f8fa'; @@ -80,18 +83,19 @@ class MailBrandSetting extends Model public function resetCache() { - Cache::forget(self::CACHE_KEY); + Cache::forget(self::instance()->cacheKey); } public static function renderCss() { - if (Cache::has(self::CACHE_KEY)) { - return Cache::get(self::CACHE_KEY); + $cacheKey = self::instance()->cacheKey; + if (Cache::has($cacheKey)) { + return Cache::get($cacheKey); } try { $customCss = self::compileCss(); - Cache::forever(self::CACHE_KEY, $customCss); + Cache::forever($cacheKey, $customCss); } catch (Exception $ex) { $customCss = '/* ' . $ex->getMessage() . ' */';