Fixes
This commit is contained in:
parent
9eae0a8eee
commit
153d3fe0b8
2 changed files with 19 additions and 1 deletions
|
@ -1,7 +1,20 @@
|
|||
<?php
|
||||
class Cache {
|
||||
protected static $templateCache = [];
|
||||
protected static $resourceCache = [];
|
||||
|
||||
public static function getTemplateFromCache(string $name) {
|
||||
if (isset(self::$templateCache[$name])) {
|
||||
return self::$templateCache[$name];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function setTemplateToCache(string $name, $data) {
|
||||
self::$templateCache[$name] = $data;
|
||||
}
|
||||
|
||||
protected static function fillResourceCache() {
|
||||
$db = new Database();
|
||||
$sql = "SELECT * FROM `resources`";
|
||||
|
|
|
@ -20,7 +20,12 @@ class Template {
|
|||
|
||||
$class = is_object($options) && isset($options->class) ? new $options->class($this, $options) : new EmptyTemplate($this, $options);
|
||||
$class->load();
|
||||
$contents = file_get_contents(TEMPLATE_DIR . "/" . $this->template);
|
||||
|
||||
$contents = Cache::getTemplateFromCache($this->template);
|
||||
if (is_null($contents)) {
|
||||
$contents = file_get_contents(TEMPLATE_DIR . "/" . $this->template);
|
||||
Cache::setTemplateToCache($this->template, $contents);
|
||||
}
|
||||
|
||||
$class->pretransform();
|
||||
// Replace includes of templates
|
||||
|
|
Loading…
Reference in a new issue