Skip to content

Commit

Permalink
Differentiates cache for API resource according to site's and API bas…
Browse files Browse the repository at this point in the history
…e path
  • Loading branch information
klamparski committed Apr 19, 2021
1 parent bbf104d commit f54843c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Classes/Domain/Repository/ApiResourceRepository.php
Expand Up @@ -9,6 +9,7 @@
use SourceBroker\T3api\Annotation\ApiResource as ApiResourceAnnotation;
use SourceBroker\T3api\Domain\Model\ApiFilter;
use SourceBroker\T3api\Domain\Model\ApiResource;
use SourceBroker\T3api\Service\RouteService;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
Expand Down Expand Up @@ -41,7 +42,7 @@ public function injectCache(CacheManager $cacheManager): void
*/
public function getAll(): array
{
$cacheIdentifier = 'ApiResourceRepository__getAll';
$cacheIdentifier = $this->buildCacheIdentifier();

$apiResources = $this->cache->get($cacheIdentifier);

Expand Down Expand Up @@ -162,4 +163,10 @@ protected function getClassNameFromFile(string $filePath): ?string

return null;
}

protected function buildCacheIdentifier(): string
{
return 'ApiResourceRepository_getAll'
. preg_replace('~[^\pL\d]+~u', '_', RouteService::getFullApiBasePath());
}
}

0 comments on commit f54843c

Please sign in to comment.