From 3f0c35af81b1eddb88277067db8cda92a76b97ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20S=C5=82omka?= Date: Wed, 13 Sep 2023 12:15:20 +0200 Subject: [PATCH] Update src/lib/Repository/NameSchema/NameSchemaService.php Co-authored-by: Andrew Longosz --- .../Repository/NameSchema/NameSchemaService.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/Repository/NameSchema/NameSchemaService.php b/src/lib/Repository/NameSchema/NameSchemaService.php index 4f1d384a33..51cd29c0b0 100644 --- a/src/lib/Repository/NameSchema/NameSchemaService.php +++ b/src/lib/Repository/NameSchema/NameSchemaService.php @@ -286,12 +286,16 @@ public function buildNames(array $tokenValues, string $nameSchema): array $names = []; foreach ($tokenValues as $languageCode => $tokenValue) { - $name = $filteredNameSchema; - foreach ($tokens as $token) { - $string = $this->resolveToken($token, $tokenValue, $groupLookupTable); - $name = str_replace($token, $string, $name); - } - $names[$languageCode] = $this->validateNameLength($name); + $names[$languageCode] = $this->validateNameLength( + str_replace( + $tokens, + array_map( + fn (string $token): string => $this->resolveToken($token, $tokenValue, $groupLookupTable), + $tokens + ), + $filteredNameSchema + ) + ); } return $names;