fix(coding style)

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
Marcel Klehr 2024-01-10 16:15:06 +01:00
parent 1db8888f99
commit 970eb692d1
1 changed files with 7 additions and 7 deletions

View File

@ -77,17 +77,17 @@ class TranslationManager implements ITranslationManager {
$precedence = json_decode($json, true); $precedence = json_decode($json, true);
$newProviders = []; $newProviders = [];
foreach ($precedence as $className) { foreach ($precedence as $className) {
$provider = current(array_filter($providers, fn ($provider) => $provider = current(array_filter($providers, function ($provider) use ($className) {
$provider instanceof ITranslationProviderWithId ? $provider->getId() === $className : $provider::class === $className)) return $provider instanceof ITranslationProviderWithId ? $provider->getId() === $className : $provider::class === $className;
; }));
if ($provider !== false) { if ($provider !== false) {
$newProviders[] = $provider; $newProviders[] = $provider;
} }
} }
// Add all providers that haven't been added so far // Add all providers that haven't been added so far
$newProviders += array_udiff($providers, $newProviders, fn ($a, $b) => $newProviders += array_udiff($providers, $newProviders, function ($a, $b) {
($a instanceof ITranslationProviderWithId ? $a->getId() : $a::class) <=> ($b instanceof ITranslationProviderWithId ? $b->getId() : $b::class) return ($a instanceof ITranslationProviderWithId ? $a->getId() : $a::class) <=> ($b instanceof ITranslationProviderWithId ? $b->getId() : $b::class);
); });
$providers = $newProviders; $providers = $newProviders;
} }
@ -116,7 +116,7 @@ class TranslationManager implements ITranslationManager {
foreach ($providers as $provider) { foreach ($providers as $provider) {
try { try {
if ($provider instanceof ITranslationProviderWithUserId) { if ($provider instanceof ITranslationProviderWithUserId) {
$provider->setUserId($this->userSession->getUser()?->getUID()); $provider->setUserId($this->userSession->getUser()?->getUID());
} }
return $provider->translate($fromLanguage, $toLanguage, $text); return $provider->translate($fromLanguage, $toLanguage, $text);