ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
Retrieval.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
21
22use Generator;
25use ILIAS\Repository\RetrievalBase;
27
29{
30 use RetrievalBase;
31
32 protected array $data;
33
34 public function __construct(
35 \ilTaxonomyTree $tree,
36 int $parent_node_id,
37 bool $manual_sorting
38 ) {
39 $this->data = $tree->getChildsByTypeFilter($parent_node_id, ["taxn"]);
40 $this->data = \ilArrayUtil::sortArray(
41 $this->data,
42 $manual_sorting ? "order_nr" : "title",
43 "asc",
44 false
45 );
46 foreach ($this->data as &$row) {
47 $row["id"] = (int) $row["child"];
48 }
49 unset($row);
50 }
51
52 public function getData(
53 array $fields,
54 ?Range $range = null,
55 ?Order $order = null,
56 array $filter = [],
57 array $parameters = []
58 ): Generator {
59 $data = $this->applyOrder($this->data, $order);
60 $data = $this->applyRange($data, $range);
61
62 yield from $data;
63 }
64
65 public function count(array $filter, array $parameters): int
66 {
67 return count($this->data);
68 }
69
70 public function isFieldNumeric(string $field): bool
71 {
72 return $field === "order_nr" || $field === "child";
73 }
74}
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
isFieldNumeric(string $field)
Definition: Retrieval.php:70
__construct(\ilTaxonomyTree $tree, int $parent_node_id, bool $manual_sorting)
Definition: Retrieval.php:34
count(array $filter, array $parameters)
Definition: Retrieval.php:65
getData(array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
Definition: Retrieval.php:52
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getChildsByTypeFilter(int $a_node_id, array $a_types, string $a_order="", string $a_direction="ASC")
get child nodes of given node by object type