From d4353118d9ce276479d6cb57968de0b051413009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 2 Nov 2019 21:18:46 +0100 Subject: [PATCH] Cache the tools tree for each locale separately. This fixes the problem that tools tree contained links to the wrong language. --- src/Services/UserCacheKeyGenerator.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Services/UserCacheKeyGenerator.php b/src/Services/UserCacheKeyGenerator.php index 5422e53e..7b884cda 100644 --- a/src/Services/UserCacheKeyGenerator.php +++ b/src/Services/UserCacheKeyGenerator.php @@ -24,6 +24,9 @@ namespace App\Services; use App\Entity\UserSystem\User; +use Nyholm\Psr7\Request; +use Symfony\Component\Intl\Locale\Locale; +use Symfony\Component\Intl\Locales; use Symfony\Component\Security\Core\Security; /** @@ -47,6 +50,8 @@ class UserCacheKeyGenerator */ public function generateKey(User $user = null) : string { + $locale = \Locale::getDefault(); + //If no user was specified, use the currently used one. if ($user === null) { $user = $this->security->getUser(); @@ -59,6 +64,6 @@ class UserCacheKeyGenerator } //In the most cases we can just use the username (its unique) - return "user_" . $user->getUsername(); + return "user_" . $user->getUsername() . '_' . $locale; } } \ No newline at end of file