Skip to content

Commit

Permalink
OXDEV-7768 Add shop identifier to template cache
Browse files Browse the repository at this point in the history
  • Loading branch information
AshrafOxid committed Feb 12, 2024
1 parent c5dc25e commit 40a01b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/TwigEngineConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,6 +18,7 @@ public function __construct(
private ContextInterface $context,
private TwigContextInterface $twigContext,
private bool $disableTemplateCaching,
private ShopTemplateCacheServiceInterface $shopTemplateCacheService
) {
}

Expand All @@ -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()),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ final class ModuleControllerRenderTest extends TestCase
];
private const THEME = 'testTheme';

private int $shopID = 1;

protected function setUp(): void
{
parent::setUp();
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 40a01b3

Please sign in to comment.