ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
TermPageRetrieval.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Generator;
24use ilCtrl;
30
32{
33 protected array $term_data;
34
35 public function __construct(
36 protected ilObjGlossary $glossary,
37 protected ilCtrl $ctrl
38 ) {
39 }
40
41 protected function getTermData(): array
42 {
43 if (isset($this->term_data)) {
44 return $this->term_data;
45 }
46 $this->term_data = [];
47 foreach ($this->glossary->getTermList() as $term) {
48 $this->term_data[$term['id']] = $term;
49 }
50 return $this->term_data;
51 }
52
56 public function getPossibleTypes(): Generator
57 {
58 yield 'term:pg';
59 }
60
64 public function getAllIDsForType(string $type): Generator
65 {
66 if ($type !== 'term:pg') {
67 return;
68 }
69 foreach ($this->getTermData() as $term) {
70 yield (int) $term['id'];
71 }
72 }
73
74 public function getLinkToSubObject(string $type, int $id): string
75 {
76 if ($type !== 'term:pg') {
77 return '';
78 }
79
80 $this->ctrl->setParameterByClass(ilGlossaryDefPageGUI::class, 'term_id', $id);
81 $link = $this->ctrl->getLinkTargetByClass([
82 ilGlossaryTermGUI::class,
83 ilTermDefinitionEditorGUI::class,
84 ilGlossaryDefPageGUI::class
85 ], 'edit');
86 $this->ctrl->clearParameterByClass(ilGlossaryDefPageGUI::class, 'term_id');
87 return $link;
88 }
89
90 public function getTitleOfSubObject(string $type, int $id): string
91 {
92 if ($type !== 'term:pg') {
93 return '';
94 }
95 return $this->getTermData()[$id]['term'] ?? '';
96 }
97}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(protected ilObjGlossary $glossary, protected ilCtrl $ctrl)
Class ilCtrl provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...