Skip to content

Commit

Permalink
[TASK] Update CacheWarmup command for new cache implementation via AJAX
Browse files Browse the repository at this point in the history
  • Loading branch information
einpraegsam committed Sep 19, 2023
1 parent 086359a commit c916ccd
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 263 deletions.
2 changes: 1 addition & 1 deletion Classes/Backend/Units/AbstractUnit.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected function assignAdditionalVariables(): array
protected function getArgument(string $key): string
{
if (array_key_exists($key, $this->arguments)) {
return $this->arguments[$key];
return (string)$this->arguments[$key];
}
return '';
}
Expand Down
22 changes: 8 additions & 14 deletions Classes/Command/LuxCacheWarmupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);
namespace In2code\Lux\Command;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\Exception as ExceptionDbalDriver;
use Doctrine\DBAL\Exception as ExceptionDbal;
use In2code\Lux\Domain\Cache\CacheLayer;
Expand Down Expand Up @@ -38,12 +39,6 @@ public function configure()
'commaseparated routes like "lux_LuxAnalysis,lux_LuxLead,web_layout"',
implode(',', CacheLayerUtility::getCachelayerRoutes())
);
$this->addArgument(
'domain',
InputArgument::OPTIONAL,
'Specify domain if no domain in siteconfiguration like "https://domain.org"',
''
);
}

/**
Expand All @@ -58,6 +53,7 @@ public function configure()
* @throws RouteNotFoundException
* @throws UnexpectedValueException
* @throws ExceptionDbal
* @throws DBALException
*/
public function execute(InputInterface $input, OutputInterface $output): int
{
Expand All @@ -75,46 +71,44 @@ public function execute(InputInterface $input, OutputInterface $output): int

$configuration = CacheLayerUtility::getCacheLayerConfigurationByRoute($route);
if ($configuration['multiple'] === false) {
$this->warmupSingleLayer($route, $input->getArgument('domain'), $configuration);
$this->warmupSingleLayer($route, $configuration);
} else {
$this->warmupMultipleLayers($route, $input->getArgument('domain'), $configuration);
$this->warmupMultipleLayers($route, $configuration);
}
}
return self::SUCCESS;
}

/**
* @param string $route
* @param string $domain
* @param array $configuration
* @return void
* @throws RouteNotFoundException
* @throws UnexpectedValueException
* @throws ConfigurationException
*/
protected function warmupSingleLayer(string $route, string $domain, array $configuration): void
protected function warmupSingleLayer(string $route, array $configuration): void
{
$this->cacheWarmup->warmup($route, $domain, $configuration['arguments'], $this->output);
$this->cacheWarmup->warmup($route, $configuration['arguments'], $this->output);
}

/**
* @param string $route
* @param string $domain
* @param array $configuration
* @return void
* @throws ExceptionDbalDriver
* @throws RouteNotFoundException
* @throws UnexpectedValueException
* @throws ConfigurationException
* @throws ExceptionDbal
* @throws DBALException
*/
protected function warmupMultipleLayers(string $route, string $domain, array $configuration): void
protected function warmupMultipleLayers(string $route, array $configuration): void
{
$pageRepository = GeneralUtility::makeInstance(PageRepository::class);
foreach ($pageRepository->getPageIdentifiersFromNormalDokTypes() as $row) {
$this->cacheWarmup->warmup(
$route,
$domain,
$this->substituteVariablesInArguments($configuration['arguments'], $row),
$this->output
);
Expand Down
155 changes: 0 additions & 155 deletions Classes/Domain/Cache/BackendSessionFaker.php

This file was deleted.

Loading

0 comments on commit c916ccd

Please sign in to comment.