Skip to content

Commit 28f2f4a

Browse files
authored
Use one-dimensional array for cache
1 parent b760ad9 commit 28f2f4a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Plugin/Url/Scope.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,24 @@ public function afterGetBaseUrl(
2828
string $type = UrlInterface::URL_TYPE_LINK,
2929
?bool $secure = null
3030
): string {
31-
return $this->cache[$scope->getId()][$type][(int)$secure] ??= $this->process($scope, $baseUrl, $type, $secure);
31+
$isSecure = match ($secure) {
32+
true => 'true',
33+
false => 'false',
34+
default => 'null'
35+
};
36+
$cacheKey = $scope->getId() . '/' . $type . '/' . $isSecure;
37+
38+
return $this->cache[$cacheKey] ??= $this->processBaseUrl($scope, $baseUrl, $type, $secure);
3239
}
3340

34-
private function process(
35-
ScopeInterface $subject,
41+
private function processBaseUrl(
42+
ScopeInterface $scope,
3643
string $baseUrl,
3744
string $type = UrlInterface::URL_TYPE_LINK,
3845
?bool $secure = null
3946
) {
40-
return $type === UrlInterface::URL_TYPE_LINK && $subject instanceof StoreInterface && $this->config->isEnabled()
41-
? $this->uriUtils->replaceScopeCode($baseUrl, $subject)
47+
return $type === UrlInterface::URL_TYPE_LINK && $scope instanceof StoreInterface && $this->config->isEnabled()
48+
? $this->uriUtils->replaceScopeCode($baseUrl, $scope)
4249
: $baseUrl;
4350
}
4451
}

0 commit comments

Comments
 (0)