ILIAS  release_8 Revision v8.24
AbstractBaseSorter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
32abstract class AbstractBaseSorter implements CollectionSorter
33{
35 protected int $direction = SORT_ASC;
36
38 {
39 $this->resource_builder = $resource_builder;
40 $this->direction = $direction;
41 }
42
43 abstract protected function sortResourceIdentification(array $identifications): array;
44
45
47 {
48 $identifications = $collection->getResourceIdentifications();
50 $sorted = $this->sortResourceIdentification($identifications);
51 if ($this->direction == SORT_DESC) {
52 $sorted = array_reverse($sorted);
53 }
54 foreach ($sorted as $identification) {
55 $collection->add($identification);
56 }
57
58 return $collection;
59 }
60}
add(ResourceIdentification $identification)
__construct(ResourceBuilder $resource_builder, int $direction=SORT_ASC)