From 77fabcfbc66aa24271c005907c62d1793c0e3a20 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Wed, 15 Jan 2025 13:14:11 +0100 Subject: [PATCH 1/2] IBX-9293: Base site access choice loader on language code --- .../ChoiceList/Loader/SiteAccessChoiceLoader.php | 12 ++++++++++-- src/lib/Form/Type/Preview/SiteAccessChoiceType.php | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lib/Form/Type/ChoiceList/Loader/SiteAccessChoiceLoader.php b/src/lib/Form/Type/ChoiceList/Loader/SiteAccessChoiceLoader.php index 4d4ac27acf..1d6fb6e695 100644 --- a/src/lib/Form/Type/ChoiceList/Loader/SiteAccessChoiceLoader.php +++ b/src/lib/Form/Type/ChoiceList/Loader/SiteAccessChoiceLoader.php @@ -24,14 +24,18 @@ class SiteAccessChoiceLoader implements ChoiceLoaderInterface private SiteAccessNameGeneratorInterface $siteAccessNameGenerator; + private ?string $languageCode; + public function __construct( SiteaccessResolverInterface $nonAdminSiteaccessResolver, SiteAccessNameGeneratorInterface $siteAccessNameGenerator, - ?Location $location = null + ?Location $location = null, + ?string $languageCode = null ) { $this->nonAdminSiteaccessResolver = $nonAdminSiteaccessResolver; $this->location = $location; $this->siteAccessNameGenerator = $siteAccessNameGenerator; + $this->languageCode = $languageCode; } /** @@ -41,7 +45,11 @@ public function getChoiceList(): array { $siteAccesses = $this->location === null ? $this->nonAdminSiteaccessResolver->getSiteAccessesList() - : $this->nonAdminSiteaccessResolver->getSiteAccessesListForLocation(($this->location)); + : $this->nonAdminSiteaccessResolver->getSiteAccessesListForLocation( + $this->location, + null, + $this->languageCode + ); $data = []; foreach ($siteAccesses as $siteAccess) { diff --git a/src/lib/Form/Type/Preview/SiteAccessChoiceType.php b/src/lib/Form/Type/Preview/SiteAccessChoiceType.php index 7f8c851a1c..6324ef40f9 100644 --- a/src/lib/Form/Type/Preview/SiteAccessChoiceType.php +++ b/src/lib/Form/Type/Preview/SiteAccessChoiceType.php @@ -51,7 +51,8 @@ public function configureOptions(OptionsResolver $resolver): void new SiteAccessChoiceLoader( $this->siteAccessResolver, $this->siteAccessNameGenerator, - $options['location'] + $options['location'], + $options['languageCode'], ), $this->urlGenerator, $options['content']->id, From 33a77c1d08b951a7295ce686c17697acdb2d226a Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Wed, 15 Jan 2025 13:22:33 +0100 Subject: [PATCH 2/2] IBX-9293: Use default language code in `getContentPreviewItem` --- src/lib/Menu/ContentRightSidebarBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Menu/ContentRightSidebarBuilder.php b/src/lib/Menu/ContentRightSidebarBuilder.php index 0372f0abed..84d5085c5b 100644 --- a/src/lib/Menu/ContentRightSidebarBuilder.php +++ b/src/lib/Menu/ContentRightSidebarBuilder.php @@ -477,7 +477,7 @@ private function getContentPreviewItem( array $options ): ItemInterface { $versionNo = $content->getVersionInfo()->versionNo; - $languageCode = $content->contentInfo->mainLanguageCode; + $languageCode = $content->getDefaultLanguageCode(); $siteAccesses = $this->siteaccessResolver->getSiteAccessesListForLocation( $location,