ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilPluginInfo.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 {
30  protected string $id;
31  protected string $name;
32  protected string $type;
33  protected bool $activated;
35  protected ?int $current_db_version;
39  protected string $responsible;
40  protected string $responsible_mail;
42  protected bool $supports_export;
43  protected bool $supports_cli_setup;
44 
45  public function __construct(
46  Version $actual_ilias_version,
47  ilPluginSlotInfo $pluginslot,
48  string $id,
49  string $name,
50  string $type,
51  bool $activated,
52  ?Version $current_version,
53  ?int $current_db_version,
54  Version $available_version,
55  Version $minimum_ilias_version,
56  Version $maximum_ilias_version,
57  string $responsible,
58  string $responsible_mail,
59  bool $supports_learning_progress,
60  bool $supports_export,
61  bool $supports_cli_setup
62  ) {
63  if ($current_version === null && $current_db_version !== null) {
64  throw new \InvalidArgumentException(
65  "If there is no current version for the plugin, we also should not " .
66  "have a db-version."
67  );
68  }
69  $this->actual_ilias_version = $actual_ilias_version;
70  $this->pluginslot = $pluginslot;
71  $this->id = $id;
72  $this->name = $name;
73  $this->type = $type;
74  $this->activated = $activated;
75  $this->current_version = $current_version;
76  $this->current_db_version = $current_db_version;
77  $this->available_version = $available_version;
78  $this->minimum_ilias_version = $minimum_ilias_version;
79  $this->maximum_ilias_version = $maximum_ilias_version;
80  $this->responsible = $responsible;
81  $this->responsible_mail = $responsible_mail;
82  $this->supports_learning_progress = $supports_learning_progress;
83  $this->supports_export = $supports_export;
84  $this->supports_cli_setup = $supports_cli_setup;
85  }
86 
87  public function getPluginSlot(): ilPluginSlotInfo
88  {
89  return $this->pluginslot;
90  }
91 
92  public function getComponent(): ilComponentInfo
93  {
94  return $this->pluginslot->getComponent();
95  }
96 
97  public function getId(): string
98  {
99  return $this->id;
100  }
101 
102  public function getName(): string
103  {
104  return $this->name;
105  }
106 
107  public function getType(): string
108  {
109  return $this->type;
110  }
111 
112  public function getPath(): string
113  {
114  return implode('/', [
116  $this->getType(),
117  $this->getComponent()->getName(),
118  $this->getPluginSlot()->getName(),
119  $this->getName()
120  ]);
121  }
122 
123  public function getClassName(): string
124  {
125  return "il" . $this->getName() . "Plugin";
126  }
127 
128  public function getConfigGUIClassName(): string
129  {
130  return "il" . $this->getName() . "ConfigGUI";
131  }
132 
137  public function isActivated(): bool
138  {
139  return $this->activated;
140  }
141 
142  public function getCurrentVersion(): ?Version
143  {
144  return $this->current_version;
145  }
146 
147  public function getCurrentDBVersion(): ?int
148  {
150  }
151 
152  public function getAvailableVersion(): Version
153  {
155  }
156 
157  public function getMinimumILIASVersion(): Version
158  {
160  }
161 
162  public function getMaximumILIASVersion(): Version
163  {
165  }
166 
167  public function getResponsible(): string
168  {
169  return $this->responsible;
170  }
171 
172  public function getResponsibleMail(): string
173  {
175  }
176 
177  public function supportsLearningProgress(): bool
178  {
180  }
181 
182  public function supportsExport(): bool
183  {
184  return $this->supports_export;
185  }
186 
187  public function supportsCLISetup(): bool
188  {
190  }
191 
195  public function isInstalled(): bool
196  {
197  return $this->current_version !== null;
198  }
199 
203  public function isUpdateRequired(): bool
204  {
205  return $this->isInstalled() && !$this->current_version->equals($this->available_version);
206  }
207 
212  public function isVersionToOld(): bool
213  {
214  return $this->current_version->isGreaterThan($this->available_version);
215  }
216 
221  public function isCompliantToILIAS(): bool
222  {
223  return
224  $this->actual_ilias_version->isGreaterThanOrEquals($this->minimum_ilias_version)
225  && $this->actual_ilias_version->isSmallerThanOrEquals($this->maximum_ilias_version);
226  }
227 
231  public function isActivationPossible(): bool
232  {
233  return $this->isCompliantToILIAS()
234  && $this->isInstalled()
235  && !$this->isVersionToOld()
236  && !$this->isUpdateRequired();
237  }
238 
242  public function isActive(): bool
243  {
244  return $this->isActivationPossible()
245  && $this->isActivated();
246  }
247 
254  public function getReasonForInactivity(): string
255  {
256  if ($this->isActive()) {
257  throw new \LogicException(
258  "Plugin is active, so no reason for inactivity."
259  );
260  }
261 
262  if (!$this->isCompliantToILIAS()) {
263  return "cmps_needs_matching_ilias_version";
264  }
265 
266  if (!$this->isInstalled()) {
267  return "cmps_must_installed";
268  }
269 
270  if ($this->isVersionToOld()) {
271  return "cmps_needs_upgrade";
272  }
273 
274  if ($this->isUpdateRequired()) {
275  return "cmps_needs_update";
276  }
277 
278  if (!$this->isActivated()) {
279  return "cmps_not_activated";
280  }
281 
282  throw new \LogicException(
283  "Unknown reason for inactivity of the plugin."
284  );
285  }
286 }
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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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)