ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
Retrieval.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Generator;
26use ILIAS\Repository\RetrievalBase;
28use ilLMObject;
29
31{
32 use RetrievalBase;
33
34 protected ?array $data = null;
35
36 public function __construct(
37 protected int $lm_id,
38 protected string $lang
39 ) {
40 }
41
42 public function getData(
43 array $fields,
44 ?Range $range = null,
45 ?Order $order = null,
46 array $filter = [],
47 array $parameters = []
48 ): Generator {
49 $data = $this->getShortTitles();
50 $data = $this->applyOrder($data, $order);
51 $data = $this->applyRange($data, $range);
52
53 yield from $data;
54 }
55
56 public function count(array $filter, array $parameters): int
57 {
58 return count($this->getShortTitles());
59 }
60
61 public function isFieldNumeric(string $field): bool
62 {
63 return $field === "id";
64 }
65
66 protected function getShortTitles(): array
67 {
68 if ($this->data !== null) {
69 return $this->data;
70 }
71
72 $data = [];
73 foreach (ilLMObject::getShortTitles($this->lm_id, $this->lang) as $short_title) {
74 $data[] = [
75 "id" => (int) $short_title["obj_id"],
76 "title" => $short_title["title"],
77 "short_title" => $short_title["short_title"],
78 "default_title" => $short_title["default_title"] ?? "",
79 "default_short_title" => $short_title["default_short_title"] ?? ""
80 ];
81 }
82
83 return $this->data = $data;
84 }
85}
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
count(array $filter, array $parameters)
Definition: Retrieval.php:56
__construct(protected int $lm_id, protected string $lang)
Definition: Retrieval.php:36
getData(array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
Definition: Retrieval.php:42
Class ilLMObject.
static getShortTitles(int $a_lm_id, string $a_lang="-")
$data
Definition: storeScorm.php:45