ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilFooterCustomGroupsProvider.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 use ILIAS\Data\URI;
28 
33 {
36 
37  public function __construct(Container $dic)
38  {
39  parent::__construct($dic);
40  $this->groups_repository = new GroupsRepositoryDB($dic->database(), $this);
41  $this->entries_repository = new EntriesRepositoryDB($dic->database(), $this);
42  }
43 
45  {
46  return $this->id_factory->identifier(uniqid('', true));
47  }
48 
50  {
52  }
53 
55  {
57  }
58 
59 
60 
61  public function getGroups(): array
62  {
63  $groups = [];
64 
65  foreach ($this->groups_repository->all() as $group) {
66  if ($group->isCore()) {
67  continue;
68  }
69  if (!$group->isActive()) {
70  continue;
71  }
72  $groups[] = $this->item_factory->group(
73  $this->dic->globalScreen()->identification()->fromSerializedIdentification($group->getId()),
74  $group->getTitle(),
75  );
76  }
77 
78  return $groups;
79  }
80 
81  public function getEntries(): array
82  {
83  $entries = [];
84 
85  foreach ($this->entries_repository->all() as $entry) {
86  if ($entry->isCore()) {
87  continue;
88  }
89  if (!$entry->isActive()) {
90  continue;
91  }
92  try {
93  $action = new URI($entry->getAction());
94  } catch (Throwable) {
95  continue;
96  }
97 
98  $entries[] = $this->item_factory->link(
99  $this->dic->globalScreen()->identification()->fromSerializedIdentification($entry->getId()),
100  $entry->getTitle(),
101  )->withParent(
102  $this->dic->globalScreen()->identification()->fromSerializedIdentification($entry->getParent())
103  )->withAction(
104  $action
105  )->withOpenInNewViewport($entry->isExternal());
106  }
107 
108  return $entries;
109  }
110 
111  private function buildURI(string $from_path): URI
112  {
113  $request = $this->dic->http()->request()->getUri();
114  return new URI($request->getScheme() . '://' . $request->getHost() . '/' . ltrim($from_path, '/'));
115  }
116 
117  public function getAdditionalTexts(): array
118  {
119  return [];
120  }
121 
122  public function getPermanentURI(): ?Permanent
123  {
124  return null;
125  }
126 
127  private function txt(string $key): string
128  {
129  return $this->dic->language()->txt($key);
130  }
131 
132 }
database()
Get interface to the Database.
Definition: Container.php:42
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
readonly EntriesRepositoryDB $entries_repository
The scope of this class is split ilias-conform URI&#39;s into components.
Definition: URI.php:34
withParent(IdentificationInterface $identification)
__construct(Container $dic, ilPlugin $plugin)
$dic
Definition: ltiresult.php:33