Skip to content

Commit

Permalink
do not initialize contao framework at cache warmup
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Dec 4, 2024
1 parent 2191a0d commit e567c2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.8.5] - 2024-12-04
- Fixed: do not initialize contao framework at cache warmup

## [1.8.4] - 2024-11-19
- Fixed: do not throw an exception in backend if templates only exists in theme folder

Expand Down
16 changes: 5 additions & 11 deletions src/Cache/TemplateCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace HeimrichHannot\TwigSupportBundle\Cache;

use Contao\CoreBundle\Framework\ContaoFramework;
use HeimrichHannot\TwigSupportBundle\Filesystem\TwigTemplateLocator;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
Expand All @@ -22,27 +21,20 @@ class TemplateCache implements CacheWarmerInterface, CacheClearerInterface

protected TwigTemplateLocator $templateLocator;
protected FilesystemAdapter $templateCache;
private ContaoFramework $contaoFramework;

/**
* TemplateCacheWarmer constructor.
*/
public function __construct(TwigTemplateLocator $templateLocator, FilesystemAdapter $templateCache, ContaoFramework $contaoFramework)
public function __construct(TwigTemplateLocator $templateLocator, FilesystemAdapter $templateCache)
{
$this->templateLocator = $templateLocator;
$this->templateCache = $templateCache;
$this->contaoFramework = $contaoFramework;
}

public function isOptional()
public function isOptional(): bool
{
return true;
}

public function warmUp($cacheDir): void
public function warmUp($cacheDir): array
{
$this->contaoFramework->initialize();

$this->templateCache->save(
$this->templateCache
->getItem(static::TEMPLATES_WITH_EXTENSION_CACHE_KEY)
Expand All @@ -53,6 +45,8 @@ public function warmUp($cacheDir): void
->getItem(static::TEMPLATES_WITHOUT_EXTENSION_CACHE_KEY)
->set($this->templateLocator->getTemplates(false, true))
);

return [];
}

public function clear($cacheDir): void
Expand Down

0 comments on commit e567c2e

Please sign in to comment.