ILIAS  release_8 Revision v8.24
class.ilPluginInfo.php
Go to the documentation of this file.
1<?php
19declare(strict_types=1);
20
22
27{
30 protected string $id;
31 protected string $name;
32 protected bool $activated;
34 protected ?int $current_db_version;
38 protected string $responsible;
39 protected string $responsible_mail;
41 protected bool $supports_export;
42 protected bool $supports_cli_setup;
43
44 public function __construct(
47 string $id,
48 string $name,
49 bool $activated,
55 string $responsible,
56 string $responsible_mail,
60 ) {
61 if ($current_version === null && $current_db_version !== null) {
62 throw new \InvalidArgumentException(
63 "If there is no current version for the plugin, we also should not " .
64 "have a db-version."
65 );
66 }
67 $this->actual_ilias_version = $actual_ilias_version;
68 $this->pluginslot = $pluginslot;
69 $this->id = $id;
70 $this->name = $name;
71 $this->activated = $activated;
72 $this->current_version = $current_version;
73 $this->current_db_version = $current_db_version;
74 $this->available_version = $available_version;
75 $this->minimum_ilias_version = $minimum_ilias_version;
76 $this->maximum_ilias_version = $maximum_ilias_version;
77 $this->responsible = $responsible;
78 $this->responsible_mail = $responsible_mail;
79 $this->supports_learning_progress = $supports_learning_progress;
80 $this->supports_export = $supports_export;
81 $this->supports_cli_setup = $supports_cli_setup;
82 }
83
85 {
86 return $this->pluginslot;
87 }
88
89 public function getComponent(): ilComponentInfo
90 {
91 return $this->pluginslot->getComponent();
92 }
93
94 public function getId(): string
95 {
96 return $this->id;
97 }
98
99 public function getName(): string
100 {
101 return $this->name;
102 }
103
104 public function getPath(): string
105 {
106 return $this->pluginslot->getPath() . "/" . $this->getName();
107 }
108
109 public function getClassName(): string
110 {
111 return "il" . $this->getName() . "Plugin";
112 }
113
114 public function getConfigGUIClassName(): string
115 {
116 return "il" . $this->getName() . "ConfigGUI";
117 }
118
123 public function isActivated(): bool
124 {
125 return $this->activated;
126 }
127
128 public function getCurrentVersion(): ?Version
129 {
131 }
132
133 public function getCurrentDBVersion(): ?int
134 {
136 }
137
138 public function getAvailableVersion(): Version
139 {
141 }
142
144 {
146 }
147
149 {
151 }
152
153 public function getResponsible(): string
154 {
155 return $this->responsible;
156 }
157
158 public function getResponsibleMail(): string
159 {
161 }
162
163 public function supportsLearningProgress(): bool
164 {
166 }
167
168 public function supportsExport(): bool
169 {
171 }
172
173 public function supportsCLISetup(): bool
174 {
176 }
177
181 public function isInstalled(): bool
182 {
183 return $this->current_version !== null;
184 }
185
189 public function isUpdateRequired(): bool
190 {
191 return $this->isInstalled() && !$this->current_version->equals($this->available_version);
192 }
193
198 public function isVersionToOld(): bool
199 {
200 return $this->current_version->isGreaterThan($this->available_version);
201 }
202
207 public function isCompliantToILIAS(): bool
208 {
209 return
210 $this->actual_ilias_version->isGreaterThanOrEquals($this->minimum_ilias_version)
211 && $this->actual_ilias_version->isSmallerThanOrEquals($this->maximum_ilias_version);
212 }
213
217 public function isActivationPossible(): bool
218 {
219 return $this->isCompliantToILIAS()
220 && $this->isInstalled()
221 && !$this->isVersionToOld()
222 && !$this->isUpdateRequired();
223 }
224
228 public function isActive(): bool
229 {
230 return $this->isActivationPossible()
231 && $this->isActivated();
232 }
233
240 public function getReasonForInactivity(): string
241 {
242 if ($this->isActive()) {
243 throw new \LogicException(
244 "Plugin is active, so no reason for inactivity."
245 );
246 }
247
248 if (!$this->isCompliantToILIAS()) {
249 return "cmps_needs_matching_ilias_version";
250 }
251
252 if (!$this->isInstalled()) {
253 return "cmps_must_installed";
254 }
255
256 if ($this->isVersionToOld()) {
257 return "cmps_needs_upgrade";
258 }
259
260 if ($this->isUpdateRequired()) {
261 return "cmps_needs_update";
262 }
263
264 if (!$this->isActivated()) {
265 return "cmps_not_activated";
266 }
267
268 throw new \LogicException(
269 "Unknown reason for inactivity of the plugin."
270 );
271 }
272}
A version number that consists of three numbers (major, minor, patch).
Definition: Version.php:27
Simple value class for basic information about a component.
Simple value class for information about a plugin.
__construct(Version $actual_ilias_version, ilPluginSlotInfo $pluginslot, string $id, string $name, bool $activated, ?Version $current_version, ?int $current_db_version, Version $available_version, Version $minimum_ilias_version, Version $maximum_ilias_version, string $responsible, string $responsible_mail, bool $supports_learning_progress, bool $supports_export, bool $supports_cli_setup)
isInstalled()
"Installed" tells if the plugin has some installed version.
isActive()
Is this plugin active right now?
getReasonForInactivity()
Which is the reason for the inactivity?
Version $maximum_ilias_version
isCompliantToILIAS()
"ILIAS Version compliance" tells if the plugin can be operated with the given ILIAS version.
isActivationPossible()
Can this plugin be activated right now.
Version $available_version
bool $supports_learning_progress
ilPluginSlotInfo $pluginslot
Version $current_version
isUpdateRequired()
"Update required" tells if the plugin needs an update.
Version $minimum_ilias_version
isActivated()
"activated" tells if the administrator of the installation wants the plugin to be effective.
Version $actual_ilias_version
isVersionToOld()
"Version to old" tells if the plugin code has a version that is below the version that was updated la...
Simple value class for basic information about a pluginslot.