ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Map.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use Closure;
28
33class Map extends AbstractMap
34{
35 #[\Override]
36 protected function getTitleSorter(): Closure
37 {
38 return static function (isItem $item_one, isItem $item_two): int {
39 if (!$item_one instanceof hasTitle || !$item_two instanceof hasTitle) {
40 return 0;
41 }
42
43 return strnatcmp($item_one->getTitle(), $item_two->getTitle());
44 };
45 }
46
47 #[\Override]
48 protected function getPositionSorter(): Closure
49 {
50 return static fn(isItem $item_one, isItem $item_two): int => $item_one->getPosition() - $item_two->getPosition(
51 );
52 }
53
54 #[\Override]
55 public function sort(): void
56 {
58
59 $replace_children_sorted = function (isItem &$item): void {
60 if ($item instanceof isGroup) {
61 $children = $item->getEntries();
62 uasort($children, $this->getPositionSorter());
63 $item = $item->withEntries($children);
64 }
65 };
66 $this->walk($replace_children_sorted);
67 }
68}
getPosition()
Return the default position for installation, this will be overridden by the configuration later.