ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Map.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 use Closure;
28 
33 class 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  {
57  parent::sort();
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...
sort()
description: > Example for rendering a Sort Glyph.
Definition: sort.php:41