ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilPluginInfo.php
Go to the documentation of this file.
1 <?php
2 
20 declare(strict_types=1);
21 
23 
28 {
31  protected string $id;
32  protected string $name;
33  protected string $type;
34  protected bool $activated;
36  protected ?int $current_db_version;
40  protected string $responsible;
41  protected string $responsible_mail;
43  protected bool $supports_export;
44  protected bool $supports_cli_setup;
45 
46  public function __construct(
47  Version $actual_ilias_version,
48  ilPluginSlotInfo $pluginslot,
49  string $id,
50  string $name,
51  string $type,
52  bool $activated,
53  ?Version $current_version,
54  ?int $current_db_version,
55  Version $available_version,
56  Version $minimum_ilias_version,
57  Version $maximum_ilias_version,
58  string $responsible,
59  string $responsible_mail,
60  bool $supports_learning_progress,
61  bool $supports_export,
62  bool $supports_cli_setup
63  ) {
64  if ($current_version === null && $current_db_version !== null) {
65  throw new \InvalidArgumentException(
66  "If there is no current version for the plugin, we also should not " .
67  "have a db-version."
68  );
69  }
70  $this->actual_ilias_version = $actual_ilias_version;
71  $this->pluginslot = $pluginslot;
72  $this->id = $id;
73  $this->name = $name;
74  $this->type = $type;
75  $this->activated = $activated;
76  $this->current_version = $current_version;
77  $this->current_db_version = $current_db_version;
78  $this->available_version = $available_version;
79  $this->minimum_ilias_version = $minimum_ilias_version;
80  $this->maximum_ilias_version = $maximum_ilias_version;
81  $this->responsible = $responsible;
82  $this->responsible_mail = $responsible_mail;
83  $this->supports_learning_progress = $supports_learning_progress;
84  $this->supports_export = $supports_export;
85  $this->supports_cli_setup = $supports_cli_setup;
86  }
87 
88  public function getPluginSlot(): ilPluginSlotInfo
89  {
90  return $this->pluginslot;
91  }
92 
93  public function getComponent(): ilComponentInfo
94  {
95  return $this->pluginslot->getComponent();
96  }
97 
98  public function getId(): string
99  {
100  return $this->id;
101  }
102 
103  public function getName(): string
104  {
105  return $this->name;
106  }
107 
108  public function getType(): string
109  {
110  return $this->type;
111  }
112 
113  public function getPath(): string
114  {
115  return implode('/', [
117  $this->getType(),
118  $this->getComponent()->getName(),
119  $this->getPluginSlot()->getName(),
120  $this->getName()
121  ]);
122  }
123 
124  public function getClassName(): string
125  {
126  return "il" . $this->getName() . "Plugin";
127  }
128 
129  public function getConfigGUIClassName(): string
130  {
131  return "il" . $this->getName() . "ConfigGUI";
132  }
133 
138  public function isActivated(): bool
139  {
140  return $this->activated;
141  }
142 
143  public function getCurrentVersion(): ?Version
144  {
145  return $this->current_version;
146  }
147 
148  public function getCurrentDBVersion(): ?int
149  {
151  }
152 
153  public function getAvailableVersion(): Version
154  {
156  }
157 
158  public function getMinimumILIASVersion(): Version
159  {
161  }
162 
163  public function getMaximumILIASVersion(): Version
164  {
166  }
167 
168  public function getResponsible(): string
169  {
170  return $this->responsible;
171  }
172 
173  public function getResponsibleMail(): string
174  {
176  }
177 
178  public function supportsLearningProgress(): bool
179  {
181  }
182 
183  public function supportsExport(): bool
184  {
185  return $this->supports_export;
186  }
187 
188  public function supportsCLISetup(): bool
189  {
191  }
192 
196  public function isInstalled(): bool
197  {
198  return $this->current_version !== null;
199  }
200 
204  public function isUpdateRequired(): bool
205  {
206  return $this->isInstalled() && !$this->current_version->equals($this->available_version);
207  }
208 
213  public function isVersionToOld(): bool
214  {
215  return $this->current_version->isGreaterThan($this->available_version);
216  }
217 
222  public function isCompliantToILIAS(): bool
223  {
224  return
225  $this->actual_ilias_version->isGreaterThanOrEquals($this->minimum_ilias_version)
226  && $this->actual_ilias_version->isSmallerThanOrEquals($this->maximum_ilias_version);
227  }
228 
232  public function isActivationPossible(): bool
233  {
234  return $this->isCompliantToILIAS()
235  && $this->isInstalled()
236  && !$this->isVersionToOld()
237  && !$this->isUpdateRequired();
238  }
239 
243  public function isActive(): bool
244  {
245  return $this->isActivationPossible()
246  && $this->isActivated();
247  }
248 
255  public function getReasonForInactivity(): string
256  {
257  if ($this->isActive()) {
258  throw new \LogicException(
259  "Plugin is active, so no reason for inactivity."
260  );
261  }
262 
263  if (!$this->isCompliantToILIAS()) {
264  return "cmps_needs_matching_ilias_version";
265  }
266 
267  if (!$this->isInstalled()) {
268  return "cmps_must_installed";
269  }
270 
271  if ($this->isVersionToOld()) {
272  return "cmps_needs_upgrade";
273  }
274 
275  if ($this->isUpdateRequired()) {
276  return "cmps_needs_update";
277  }
278 
279  if (!$this->isActivated()) {
280  return "cmps_not_activated";
281  }
282 
283  throw new \LogicException(
284  "Unknown reason for inactivity of the plugin."
285  );
286  }
287 }
Version $minimum_ilias_version
bool $supports_learning_progress
ilPluginSlotInfo $pluginslot
Simple value class for basic information about a pluginslot.
isActive()
Is this plugin active right now?
Version $current_version
Version $available_version
isInstalled()
"Installed" tells if the plugin has some installed version.
isActivationPossible()
Can this plugin be activated right now.
isCompliantToILIAS()
"ILIAS Version compliance" tells if the plugin can be operated with the given ILIAS version...
isUpdateRequired()
"Update required" tells if the plugin needs an update.
isVersionToOld()
"Version to old" tells if the plugin code has a version that is below the version that was updated la...
Version $maximum_ilias_version
Simple value class for information about a plugin.
getReasonForInactivity()
Which is the reason for the inactivity?
isActivated()
"activated" tells if the administrator of the installation wants the plugin to be effective...
A version number that consists of three numbers (major, minor, patch).
Definition: Version.php:26
Version $actual_ilias_version
Simple value class for basic information about a component.
__construct(Version $actual_ilias_version, ilPluginSlotInfo $pluginslot, string $id, string $name, string $type, 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)