From 40a01b3c128fa927f19a6e3df1b4748b0682621d Mon Sep 17 00:00:00 2001 From: ashraf Date: Wed, 31 Jan 2024 13:33:20 +0100 Subject: [PATCH] OXDEV-7768 Add shop identifier to template cache --- src/TwigEngineConfiguration.php | 6 +++++- .../ControllerRender/ModuleControllerRenderTest.php | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/TwigEngineConfiguration.php b/src/TwigEngineConfiguration.php index 5275607..737f05f 100644 --- a/src/TwigEngineConfiguration.php +++ b/src/TwigEngineConfiguration.php @@ -9,6 +9,7 @@ namespace OxidEsales\Twig; +use OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\ShopTemplateCacheServiceInterface; use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface; class TwigEngineConfiguration implements TwigEngineConfigurationInterface @@ -17,6 +18,7 @@ public function __construct( private ContextInterface $context, private TwigContextInterface $twigContext, private bool $disableTemplateCaching, + private ShopTemplateCacheServiceInterface $shopTemplateCacheService ) { } @@ -29,7 +31,9 @@ public function getParameters(): array { return [ 'debug' => $this->twigContext->getIsDebug(), - 'cache' => $this->disableTemplateCaching ? false : $this->context->getTemplateCacheDirectory(), + 'cache' => $this->disableTemplateCaching + ? false + : $this->shopTemplateCacheService->getShopTemplateCacheDirectory($this->context->getCurrentShopId()), ]; } } diff --git a/tests/Integration/TwigEngine/ControllerRender/ModuleControllerRenderTest.php b/tests/Integration/TwigEngine/ControllerRender/ModuleControllerRenderTest.php index 8fa5b6d..0efc1e7 100644 --- a/tests/Integration/TwigEngine/ControllerRender/ModuleControllerRenderTest.php +++ b/tests/Integration/TwigEngine/ControllerRender/ModuleControllerRenderTest.php @@ -31,6 +31,8 @@ final class ModuleControllerRenderTest extends TestCase ]; private const THEME = 'testTheme'; + private int $shopID = 1; + protected function setUp(): void { parent::setUp(); @@ -120,7 +122,7 @@ private function switchDebugMode(bool $enable): void $configFile = $this->prophesize(ConfigFile::class); $configFile->getVar('sCompileDir') ->willReturn( - $this->get(ContextInterface::class)->getTemplateCacheDirectory() + $this->get(ContextInterface::class)->getTemplateCacheDirectory($this->shopID) ); $configFile->getVar('iDebug')->willReturn($enable); Registry::set(ConfigFile::class, $configFile->reveal());