enigne/skin: don't use $globalContext to build cache dir path

This commit is contained in:
E. S. 2025-04-28 15:34:27 +03:00
parent 45f340e1e3
commit c2cb432ae6
4 changed files with 18 additions and 2 deletions

View File

@ -17,9 +17,9 @@ abstract class BaseSkin
protected \Twig\Environment $twig;
public function __construct() {
global $config, $globalContext;
global $config;
$cache_dir = $config['skin_cache_'.(isDev() ? 'dev' : 'prod').'_dir'].'/'.$globalContext->project;
$cache_dir = $this->getCacheDir();
if (!file_exists($cache_dir)) {
if (mkdir($cache_dir, $config['dirs_mode'], true))
setperm($cache_dir);
@ -35,6 +35,7 @@ abstract class BaseSkin
}
abstract protected function getTwigLoader(): LoaderInterface;
abstract protected function getCacheDir(): string;
public function set($arg1, $arg2 = null) {
if (is_array($arg1)) {

View File

@ -14,6 +14,11 @@ class ErrorSkin
return new FilesystemLoader(self::TEMPLATES_ROOT, APP_ROOT);
}
protected function getCacheDir(): string {
global $config;
return $config['skin_cache_'.(isDev() ? 'dev' : 'prod').'_dir'].'/error';
}
public function renderNotFound(): never {
global $globalContext;
if (isset($globalContext->project) && file_exists(self::TEMPLATES_ROOT.'/notfound_'.$globalContext->project.'.twig'))

View File

@ -37,6 +37,11 @@ class ForeignOneSkin
return $twig_loader;
}
protected function getCacheDir(): string {
global $config;
return $config['skin_cache_'.(isDev() ? 'dev' : 'prod').'_dir'].'/foreignone';
}
public function renderPage(string $template, array $vars = []): Response {
$this->exportStrings(['4in1']);
$this->applyGlobals();

View File

@ -22,6 +22,11 @@ class InvisibleCollegeSkin
return $twig_loader;
}
protected function getCacheDir(): string {
global $config;
return $config['skin_cache_'.(isDev() ? 'dev' : 'prod').'_dir'].'/ic';
}
/*
public function renderPage(string $template, array $vars = []): Response {
$this->exportStrings(['4in1']);