Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-1465: Prioritize current site access when choosing language #2012

Merged
merged 2 commits into from
Nov 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/lib/UI/Config/Provider/Languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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
Expand All @@ -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;
mateuszdebinski marked this conversation as resolved.
Show resolved Hide resolved
$this->siteAccesses = $siteAccesses;
}

Expand Down Expand Up @@ -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);
Expand Down