ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
PageRetrieval.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Generator;
24use ilCtrl;
27
29{
33 protected array $page_titles_by_id;
34
35 public function __construct(
36 protected PageManager $page_manager,
37 protected ilCtrl $ctrl
38 ) {
39 }
40
44 protected function getPageTitleByID(): array
45 {
46 if (isset($this->page_titles_by_id)) {
48 }
49 $this->page_titles_by_id = [];
50 foreach ($this->page_manager->getWikiPages() as $page) {
51 $this->page_titles_by_id[$page->getId()] = $page->getTitle();
52 }
54 }
55
59 public function getPossibleTypes(): Generator
60 {
61 yield 'wpg:pg';
62 }
63
67 public function getAllIDsForType(string $type): Generator
68 {
69 if ($type !== 'wpg:pg') {
70 return;
71 }
72 yield from array_keys($this->getPageTitleByID());
73 }
74
75 public function getLinkToSubObject(string $type, int $id): string
76 {
77 if ($type !== 'wpg:pg') {
78 return '';
79 }
80 return $this->page_manager->getPermaLink($id);
81 }
82
83 public function getTitleOfSubObject(string $type, int $id): string
84 {
85 if ($type !== 'wpg:pg') {
86 return '';
87 }
88 return $this->getPageTitleByID()[$id] ?? '';
89 }
90}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getLinkToSubObject(string $type, int $id)
__construct(protected PageManager $page_manager, protected ilCtrl $ctrl)
getTitleOfSubObject(string $type, int $id)
Class ilCtrl provides processing control methods.