Skip to content

Commit

Permalink
OXDEV-7768 Remove Template cache service
Browse files Browse the repository at this point in the history
  • Loading branch information
AshrafOxid committed Mar 18, 2024
1 parent db2d95d commit 1b7b63f
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 169 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
- Remove deprecated global function \makeReadable()
- Redundant `TemplateFileResolverInterface` functionality
- Smarty templates support
- `TemplateCacheService` has been replaced with a templating cache service to manage the shop's cache.
6 changes: 3 additions & 3 deletions source/Internal/Framework/Cache/Command/ClearCacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use OxidEsales\EshopCommunity\Internal\Framework\DIContainer\Service\ContainerCacheInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheServiceInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\TemplateCacheServiceInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\ShopTemplateCacheServiceInterface;
use OxidEsales\EshopCommunity\Internal\Transition\Adapter\ShopAdapterInterface;
use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface;
use Symfony\Component\Console\Command\Command;
Expand All @@ -17,7 +17,7 @@ class ClearCacheCommand extends Command
{
public function __construct(
private ShopAdapterInterface $shopAdapter,
private TemplateCacheServiceInterface $templateCacheService,
private ShopTemplateCacheServiceInterface $shopTemplateCacheService,
private ContainerCacheInterface $containerCache,
private ModuleCacheServiceInterface $moduleCacheService,
private ContextInterface $context
Expand All @@ -32,7 +32,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->templateCacheService->invalidateTemplateCache();
$this->shopTemplateCacheService->invalidateAllShopsCache();
$this->shopAdapter->invalidateModulesCache();

foreach ($this->context->getAllShopIds() as $shopId) {
Expand Down

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions source/Internal/Framework/Templating/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ services:
arguments:
Symfony\Component\Filesystem\Filesystem: '@oxid_esales.symfony.file_system'

OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\TemplateCacheServiceInterface:
class: OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\TemplateCacheService
arguments:
- '@OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface'
- '@OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\ShopTemplateCacheServiceInterface'

OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\ShopTemplateCacheServiceInterface:
class: OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\ShopTemplateCacheService
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace OxidEsales\EshopCommunity\Internal\Framework\Theme\Command;

use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheServiceInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\TemplateCacheServiceInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\ShopTemplateCacheServiceInterface;
use OxidEsales\EshopCommunity\Internal\Transition\Adapter\ShopAdapterInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -25,7 +25,7 @@ class ThemeActivateCommand extends Command

public function __construct(
private readonly ShopAdapterInterface $shopAdapter,
private readonly TemplateCacheServiceInterface $templateCacheService,
private readonly ShopTemplateCacheServiceInterface $shopTemplateCacheService,
private readonly ModuleCacheServiceInterface $moduleCacheService
) {
parent::__construct();
Expand Down Expand Up @@ -58,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$this->shopAdapter->activateTheme($themeId);
$this->moduleCacheService->invalidateAll();
$this->templateCacheService->invalidateTemplateCache();
$this->shopTemplateCacheService->invalidateAllShopsCache();
$output->writeLn('<info>' . sprintf(self::MESSAGE_THEME_ACTIVATED, $themeId) . '</info>');

return Command::SUCCESS;
Expand Down
8 changes: 0 additions & 8 deletions source/Internal/Transition/Utility/BasicContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,4 @@ public function getFacts(): Facts
}
return $this->facts;
}

public function getTemplateCacheDirectory(): string
{
return Path::join(
$this->getCacheDirectory(),
'template_cache'
);
}
}
5 changes: 0 additions & 5 deletions source/Internal/Transition/Utility/BasicContextInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,4 @@ public function getFacts(): Facts;
public function getCacheDirectory(): string;

public function getModuleCacheDirectory(): string;

/**
* @deprecated Use OxidEsales\Eshop\Internal\Framework\Templating\Cache\ShopTemplateCacheServiceInterface instead
*/
public function getTemplateCacheDirectory(): string;
}

This file was deleted.

7 changes: 0 additions & 7 deletions tests/Unit/Internal/BasicContextStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class BasicContextStub implements BasicContextInterface
private string $composerVendorName;
private string $cacheDirectory;
private string $moduleCacheDirectory;
private string $templateCacheDirectory;
private int $currentShopId;
private string $activeModuleServicesFilePath;

Expand All @@ -64,7 +63,6 @@ public function __construct()
$this->composerVendorName = $basicContext->getComposerVendorName();
$this->cacheDirectory = $basicContext->getCacheDirectory();
$this->moduleCacheDirectory = $basicContext->getModuleCacheDirectory();
$this->templateCacheDirectory = $basicContext->getTemplateCacheDirectory();
$this->currentShopId = $basicContext->getCurrentShopId();
$this->activeModuleServicesFilePath = $basicContext->getActiveModuleServicesFilePath($this->getCurrentShopId());
$this->shopConfigurableServicesFilePath = $basicContext->getShopConfigurableServicesFilePath(
Expand Down Expand Up @@ -237,11 +235,6 @@ public function getShopConfigurationDirectory(int $shopId): string
return Path::join($this->getProjectConfigurationDirectory(), 'shops', (string)$shopId);
}

public function getTemplateCacheDirectory(): string
{
return $this->templateCacheDirectory;
}

public function setTemplateCacheDirectory(string $templateCacheDirectory): void
{
$this->templateCacheDirectory = $templateCacheDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use OxidEsales\EshopCommunity\Internal\Framework\Cache\Command\ClearCacheCommand;
use OxidEsales\EshopCommunity\Internal\Framework\DIContainer\Service\ContainerCacheInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Cache\ModuleCacheServiceInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\TemplateCacheService;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\Cache\ShopTemplateCacheServiceInterface;
use OxidEsales\EshopCommunity\Internal\Transition\Adapter\ShopAdapterInterface;
use OxidEsales\EshopCommunity\Internal\Transition\Utility\ContextInterface;
use PHPUnit\Framework\TestCase;
Expand All @@ -26,8 +26,8 @@ public function testClearCacheTriggersRegularAndTemplatesCleaners(): void
$shopAdapterMock = $this->createMock(ShopAdapterInterface::class);
$shopAdapterMock->expects($this->once())->method('invalidateModulesCache');

$templateCacheServiceMock = $this->createMock(TemplateCacheService::class);
$templateCacheServiceMock->expects($this->once())->method('invalidateTemplateCache');
$shopTemplateCacheServiceMock = $this->createMock(ShopTemplateCacheServiceInterface::class);
$shopTemplateCacheServiceMock->expects($this->once())->method('invalidateAllShopsCache');

$containerCacheMock = $this->createMock(ContainerCacheInterface::class);
$containerCacheMock->expects($this->once())->method('invalidate');
Expand All @@ -40,7 +40,7 @@ public function testClearCacheTriggersRegularAndTemplatesCleaners(): void

$command = new ClearCacheCommand(
$shopAdapterMock,
$templateCacheServiceMock,
$shopTemplateCacheServiceMock,
$containerCacheMock,
$moduleCacheServiceMock,
$contextMock
Expand Down

0 comments on commit 1b7b63f

Please sign in to comment.