1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-12 08:04:05 +02:00

Themes: Implement doctrine cache #4 #5

This commit is contained in:
Awilum
2018-03-27 04:19:15 +03:00
parent e7f15a7830
commit 6eaf95a2d9

View File

@@ -34,12 +34,23 @@ class Themes
// Theme Manifest
$theme_manifest = [];
// Theme cache id
$theme_cache_id = '';
// Get current theme
$theme = Config::get('site.theme');
if (Flextype::filesystem()->exists($theme_manifest_file = THEMES_PATH . '/' . $theme . '/' . $theme . '.yml')) {
$theme_manifest = Yaml::parseFile($theme_manifest_file);
Config::set('themes.'.Config::get('site.theme'), $theme_manifest);
// Create Unique Cache ID for Theme
$theme_cache_id = md5('theme' . THEMES_PATH . $theme);
if (Cache::driver()->contains($theme_cache_id)) {
Config::set('themes.'.Config::get('site.theme'), Cache::driver()->fetch($theme_cache_id));
} else {
if (Flextype::filesystem()->exists($theme_manifest_file = THEMES_PATH . '/' . $theme . '/' . $theme . '.yml')) {
$theme_manifest = Yaml::parseFile($theme_manifest_file);
Config::set('themes.'.Config::get('site.theme'), $theme_manifest);
Cache::driver()->save($theme_cache_id, $theme_manifest);
}
}
}