ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ContProfileRetrieval.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use ILIAS\Repository\RetrievalBase;
28
30{
31 use RetrievalBase;
32
33 public function __construct(
34 protected SkillProfileService $profile_service,
35 protected \ilSkillManagementSettings $skmg_settings,
36 protected int $cont_member_role_id
37 ) {
38 }
39
40 public function getData(
41 array $fields,
42 ?Range $range = null,
43 ?Order $order = null,
44 array $filter = [],
45 array $parameters = []
46 ): \Generator {
47 $profiles = [];
48
49 if ($this->skmg_settings->getLocalAssignmentOfProfiles()) {
50 foreach ($this->profile_service->getGlobalProfilesOfRole($this->cont_member_role_id) as $gp) {
51 $profiles[] = $gp;
52 }
53 }
54 if ($this->skmg_settings->getAllowLocalProfiles()) {
55 foreach ($this->profile_service->getLocalProfilesOfRole($this->cont_member_role_id) as $lp) {
56 $profiles[] = $lp;
57 }
58 }
59
60 // convert profiles to array structure, because tables can only handle arrays
61 $profiles_array = [];
62 foreach ($profiles as $profile) {
63 $profiles_array[$profile->getId()] = [
64 "id" => $profile->getId(),
65 "profile_id" => $profile->getId(),
66 "title" => $profile->getTitle(),
67 "profile_ref_id" => $profile->getRefId()
68 ];
69 }
70 ksort($profiles_array);
71
72 $profiles_array = $this->applyOrder($profiles_array, $order);
73 $profiles_array = $this->applyRange($profiles_array, $range);
74
75 foreach ($profiles_array as $profile) {
76 yield $profile;
77 }
78 }
79
80 public function count(
81 array $filter,
82 array $parameters
83 ): int {
84 $count = 0;
85
86 if ($this->skmg_settings->getLocalAssignmentOfProfiles()) {
87 $count += count($this->profile_service->getGlobalProfilesOfRole($this->cont_member_role_id));
88 }
89 if ($this->skmg_settings->getAllowLocalProfiles()) {
90 $count += count($this->profile_service->getLocalProfilesOfRole($this->cont_member_role_id));
91 }
92
93 return $count;
94 }
95
96 public function isFieldNumeric(string $field): bool
97 {
98 return in_array($field, ["profile_id", "id"]);
99 }
100}
count(array $filter, array $parameters)
getData(array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
__construct(protected SkillProfileService $profile_service, protected \ilSkillManagementSettings $skmg_settings, protected int $cont_member_role_id)
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