Make using twig cache optional
This commit is contained in:
parent
5fcb927b5a
commit
4b05e9ea1d
1 changed files with 7 additions and 1 deletions
|
|
@ -129,6 +129,8 @@ class App
|
|||
$container = $container->build();
|
||||
|
||||
$container->set(Slim\Views\Twig::class, function (ContainerInterface $container) {
|
||||
/** @var EnvironmentService $environmentService */
|
||||
$environmentService = $container->get(EnvironmentService::class);
|
||||
foreach ($this->viewPaths as $i => $viewLocation) {
|
||||
if (!file_exists($viewLocation) || !is_dir($viewLocation)) {
|
||||
unset($this->viewPaths[$i]);
|
||||
|
|
@ -136,7 +138,11 @@ class App
|
|||
}
|
||||
|
||||
$twigCachePath = "{$this->getCachePath()}/twig";
|
||||
$twigSettings = ['cache' => $twigCachePath];
|
||||
$twigSettings = [];
|
||||
|
||||
if($environmentService->has('TWIG_CACHE') && strtolower($environmentService->get('TWIG_CACHE')) == "on") {
|
||||
$twigSettings['cache'] = $twigCachePath;
|
||||
}
|
||||
|
||||
if (!file_exists($twigCachePath)) {
|
||||
@mkdir($twigCachePath, 0777, true);
|
||||
|
|
|
|||
Loading…
Reference in a new issue