mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-22 04:16:10 +01:00
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
This commit is contained in:
parent
4a8abbe344
commit
cf2b571fda
2 changed files with 15 additions and 0 deletions
|
@ -795,4 +795,12 @@ class Event extends AbstractEntity
|
|||
{
|
||||
return $this->_languageUid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLocalizedUid()
|
||||
{
|
||||
return $this->_localizedUid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue