From cf2b571fda92219032bfe74b0aa350a49b46ba60 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 16 Mar 2021 08:10:46 +0100 Subject: [PATCH] Support manual sorting in foreign language Given: Website uses copy / free mode of localization. and Editor selects specific events to display. Then: Those events should be displayed as selected. Before this change the sorting was applied on uid of objects, which is the uid of default lanugage record. But editors might select localized uids. Therefore a fallback is added in case no object was found. Relates: #8557 --- Classes/Domain/Model/Event.php | 8 ++++++++ Classes/Domain/Repository/EventRepository.php | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/Classes/Domain/Model/Event.php b/Classes/Domain/Model/Event.php index b74e9ad..4b9a2bd 100644 --- a/Classes/Domain/Model/Event.php +++ b/Classes/Domain/Model/Event.php @@ -795,4 +795,12 @@ class Event extends AbstractEntity { return $this->_languageUid; } + + /** + * @return int + */ + public function getLocalizedUid() + { + return $this->_localizedUid; + } } diff --git a/Classes/Domain/Repository/EventRepository.php b/Classes/Domain/Repository/EventRepository.php index 403c6db..2797deb 100644 --- a/Classes/Domain/Repository/EventRepository.php +++ b/Classes/Domain/Repository/EventRepository.php @@ -95,7 +95,14 @@ class EventRepository extends Repository usort($result, function (Event $eventA, Event $eventB) use ($expectedSorting) { $positionOfA = array_search($eventA->getUid(), $expectedSorting); + if ($positionOfA === false) { + $positionOfA = array_search($eventA->getLocalizedUid(), $expectedSorting); + } + $positionOfB = array_search($eventB->getUid(), $expectedSorting); + if ($positionOfB === false) { + $positionOfB = array_search($eventB->getLocalizedUid(), $expectedSorting); + } return $positionOfA <=> $positionOfB; });