feat: manual sorting of additional services
This commit is contained in:
1 parent
045fdea923
commit
455456b6bc
9 files changed
+253
-23
No files matched your search
@@ -156,11 +156,9 @@ class AccommodationBookingService
|
||||
}
|
||||
}
|
||||
|
||||
// Additional services keep the repository order (manual position), which also makes the
|
||||
// groups appear in the order of their lowest-positioned member.
|
||||
$boardServices = $this->sortServicesByPriceThenLabel($boardServices);
|
||||
$ungrouped = $this->sortServicesByPriceThenLabel($ungrouped);
|
||||
foreach ($grouped as $groupName => $groupServices) {
|
||||
$grouped[$groupName] = $this->sortServicesByPriceThenLabel($groupServices);
|
||||
}
|
||||
|
||||
return [
|
||||
'boardServices' => $boardServices,
|
||||
@@ -171,17 +169,15 @@ class AccommodationBookingService
|
||||
}
|
||||
|
||||
/**
|
||||
* Free services (price 0) first, then alphabetically; each group sorted alphabetically.
|
||||
* Free services (price 0) first, then alphabetically.
|
||||
*
|
||||
* @template T of BoardService|AdditionalService
|
||||
* @param BoardService[] $services
|
||||
*
|
||||
* @param T[] $services
|
||||
*
|
||||
* @return T[]
|
||||
* @return BoardService[]
|
||||
*/
|
||||
private function sortServicesByPriceThenLabel(array $services): array
|
||||
{
|
||||
usort($services, static function (BoardService|AdditionalService $a, BoardService|AdditionalService $b): int {
|
||||
usort($services, static function (BoardService $a, BoardService $b): int {
|
||||
$aFree = 0 === $a->getPrice() ? 0 : 1;
|
||||
$bFree = 0 === $b->getPrice() ? 0 : 1;
|
||||
|
||||
|
||||
Reference in new issue
Block a user