/**
* @param string $dir The directory where to store the cache files
*/
public function __construct(LoaderInterface
$loader, string
$dir) { $this->loader =
$loader;
$this->dir =
$dir;
} public function load(TemplateReferenceInterface
$template): Storage|false
{ $key =
hash('sha256',
$template->
getLogicalName());
$dir =
$this->dir.\DIRECTORY_SEPARATOR.
substr($key, 0, 2
);
$file =
substr($key, 2
).'.tpl';
$path =
$dir.\DIRECTORY_SEPARATOR.
$file;
if (is_file($path)) { $this->logger?->
debug('Fetching template from cache.',
['name' =>
$template->
get('name'
)]);
return new FileStorage($path);
} if (false ===
$storage =
$this->loader->
load($template)) {