ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
RoleRecommendationRetrieval.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\Repository\RetrievalBase;
27
29{
30 use RetrievalBase;
31
32 public function __construct(
33 protected \ilRecommendedContentManager $manager,
34 protected \ilTree $tree,
35 protected int $role_id
36 ) {
37 }
38
39 public function getData(
40 array $fields,
41 ?Range $range = null,
42 ?Order $order = null,
43 array $filter = [],
44 array $parameters = []
45 ): \Generator {
46 $data = $this->collectData();
47 $data = $this->applyOrder($data, $order);
48 $data = $this->applyRange($data, $range);
49
50 yield from $data;
51 }
52
53 public function count(array $filter, array $parameters): int
54 {
55 return count($this->collectData());
56 }
57
58 public function isFieldNumeric(string $field): bool
59 {
60 return $field === 'id' || $field === 'ref_id';
61 }
62
63 protected function collectData(): array
64 {
65 $data = [];
66
67 foreach ($this->manager->getRecommendationsOfRole($this->role_id) as $ref_id) {
68 $ref_id = (int) $ref_id;
69 $data[] = [
70 'id' => $ref_id,
71 'ref_id' => $ref_id,
73 'path' => $this->formatPath($this->tree->getPathFull($ref_id))
74 ];
75 }
76
77 return $data;
78 }
79
80 protected function formatPath(array $path): string
81 {
82 return implode(' &raquo; ', array_column($path, 'title'));
83 }
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
__construct(protected \ilRecommendedContentManager $manager, protected \ilTree $tree, protected int $role_id)
getData(array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
static _lookupObjectId(int $ref_id)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
$data
Definition: storeScorm.php:45