diff --git a/src/lib/UI/Config/Provider/Languages.php b/src/lib/UI/Config/Provider/Languages.php index f683ec295a..af77796c63 100644 --- a/src/lib/UI/Config/Provider/Languages.php +++ b/src/lib/UI/Config/Provider/Languages.php @@ -10,6 +10,7 @@ use eZ\Publish\API\Repository\LanguageService; use eZ\Publish\Core\MVC\ConfigResolverInterface; +use eZ\Publish\Core\MVC\Symfony\SiteAccess; use EzSystems\EzPlatformAdminUi\UI\Config\ProviderInterface; /** @@ -26,6 +27,9 @@ class Languages implements ProviderInterface /** @var string[] */ private $siteAccesses; + /** @var \eZ\Publish\Core\MVC\Symfony\SiteAccess */ + private $siteAccess; + /** * @param \eZ\Publish\API\Repository\LanguageService $languageService * @param \eZ\Publish\Core\MVC\ConfigResolverInterface $configResolver @@ -34,10 +38,12 @@ class Languages implements ProviderInterface public function __construct( LanguageService $languageService, ConfigResolverInterface $configResolver, + SiteAccess $siteAccess, array $siteAccesses ) { $this->languageService = $languageService; $this->configResolver = $configResolver; + $this->siteAccess = $siteAccess; $this->siteAccesses = $siteAccesses; } @@ -86,8 +92,9 @@ protected function getLanguagesPriority(array $languagesMap): array { $priority = []; $fallback = []; + $siteAccesses = array_unique(array_merge([$this->siteAccess->name], $this->siteAccesses)); - foreach ($this->siteAccesses as $siteAccess) { + foreach ($siteAccesses as $siteAccess) { $siteAccessLanguages = $this->configResolver->getParameter('languages', null, $siteAccess); $priority[] = array_shift($siteAccessLanguages); $fallback = array_merge($fallback, $siteAccessLanguages);