1 | <?php |
||
2 | |||
3 | namespace LeKoala\DebugBar\View; |
||
4 | |||
5 | use LeKoala\DebugBar\Proxy\CacheProxy; |
||
0 ignored issues
–
show
|
|||
6 | use Psr\SimpleCache\CacheInterface; |
||
7 | use SilverStripe\Core\Injector\Injector; |
||
8 | use SilverStripe\TemplateEngine\SSTemplateEngine; |
||
9 | use SilverStripe\Versioned\Caching\VersionedCacheAdapter; |
||
10 | use SilverStripe\View\SSViewer; |
||
11 | use SilverStripe\View\ThemeResourceLoader; |
||
12 | |||
13 | class TemplateEngine extends SSTemplateEngine |
||
14 | { |
||
15 | protected ?string $selectedTemplatePath; |
||
16 | |||
17 | public function setTemplate(string|array $templateCandidates): static |
||
18 | { |
||
19 | parent::setTemplate($templateCandidates); |
||
20 | |||
21 | $themes = SSViewer::get_themes(); |
||
22 | |||
23 | $cacheAdapter = ThemeResourceLoader::inst()->getCache(); |
||
24 | $cacheKey = 'findTemplate_' . md5(json_encode($templateCandidates) . json_encode($themes)); |
||
25 | |||
26 | // Look for a cached result for this data set |
||
27 | if ($cacheAdapter->has($cacheKey)) { |
||
28 | $this->selectedTemplatePath = $cacheAdapter->get($cacheKey); |
||
29 | } |
||
30 | |||
31 | return $this; |
||
32 | } |
||
33 | |||
34 | public function getSelectedTemplatePath(): ?string |
||
35 | { |
||
36 | return $this->selectedTemplatePath; |
||
37 | } |
||
38 | |||
39 | public function getPartialCacheStore(): CacheInterface |
||
40 | { |
||
41 | $cache = parent::getPartialCacheStore(); |
||
42 | |||
43 | if (method_exists($cache, 'setContext')) { |
||
44 | $cache->setContext(CacheProxy::CONTEXT_TMP); |
||
45 | } |
||
46 | |||
47 | return $cache; |
||
48 | } |
||
49 | } |
||
50 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths