Skip to content

Commit f3a37ac

Browse files
authored
Merge pull request #73 from neznaika0/fix-cache-crash
fix: Error when config cache is enabled
2 parents 593517e + f08cf98 commit f3a37ac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Config/Services.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use CodeIgniter\HTTP\ResponseInterface;
88
use CodeIgniter\HTTP\UserAgent;
99
use Config\App;
10+
use Config\Optimize;
11+
use Config\Paths;
1012
use Config\Services as AppServices;
1113
use Config\Toolbar as ToolbarConfig;
1214
use Config\View as ViewConfig;
@@ -31,7 +33,10 @@ public static function renderer(?string $viewPath = null, ?ViewConfig $config =
3133
return static::getSharedInstance('renderer', $viewPath, $config);
3234
}
3335

34-
$viewPath = $viewPath ?: config('Paths')->viewDirectory;
36+
$viewPath = $viewPath ?: ((new Optimize())->configCacheEnabled ?
37+
(new Paths())->viewDirectory :
38+
config('Paths')->viewDirectory);
39+
3540
$config ??= config('View');
3641

3742
return new View($config, $viewPath, AppServices::locator(), CI_DEBUG, AppServices::logger());

0 commit comments

Comments
 (0)