Give the compiled CSS it's own cache pipe so it doesn't conflict with the deferred binding workflow

This commit is contained in:
Sam Georges 2014-11-01 10:26:43 +11:00
parent 8cb512e8dd
commit e7c33467f3
3 changed files with 20 additions and 3 deletions

View File

@ -1,3 +1,6 @@
* **Build 160** (2014-11-01)
- Various fixes to the Backend Brand settings page.
* **Build 158** (2014-10-23) * **Build 158** (2014-10-23)
- Fixes an issue where new Themes attached to a project were not being installed on update. - Fixes an issue where new Themes attached to a project were not being installed on update.
- Fixes issue where XDebug aborts the thread for maximum function count. - Fixes issue where XDebug aborts the thread for maximum function count.

View File

@ -3,6 +3,6 @@
?> ?>
<?php if (BrandSettings::isConfigured()): ?> <?php if (BrandSettings::isConfigured()): ?>
<style> <style>
<?= BrandSettings::get('rendered_css') ?> <?= BrandSettings::renderCss() ?>
</style> </style>
<?php endif ?> <?php endif ?>

View File

@ -3,6 +3,7 @@
use File; use File;
use Lang; use Lang;
use Model; use Model;
use Cache;
use Less_Parser; use Less_Parser;
/** /**
@ -26,6 +27,8 @@ class BrandSettings extends Model
'logo' => ['System\Models\File'] 'logo' => ['System\Models\File']
]; ];
const CACHE_KEY = 'backend::brand.custom_css';
// Pumpkin // Pumpkin
const PRIMARY_LIGHT = '#e67e22'; const PRIMARY_LIGHT = '#e67e22';
@ -57,9 +60,9 @@ class BrandSettings extends Model
$this->secondary_color_dark = self::SECONDARY_DARK; $this->secondary_color_dark = self::SECONDARY_DARK;
} }
public function beforeValidate() public function afterSave()
{ {
$this->rendered_css = self::renderCss(); Cache::forget(self::CACHE_KEY);
} }
public static function getLogo() public static function getLogo()
@ -73,6 +76,17 @@ class BrandSettings extends Model
} }
public static function renderCss() public static function renderCss()
{
if (Cache::has(self::CACHE_KEY)) {
return Cache::get(self::CACHE_KEY);
}
$customCss = self::compileCss();
Cache::forever(self::CACHE_KEY, $customCss);
return $customCss;
}
public static function compileCss()
{ {
$parser = new Less_Parser(['compress' => true]); $parser = new Less_Parser(['compress' => true]);