ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilNoMajorVersionSkippedConditionObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22use ILIAS\Data;
23
25{
26 protected Data\Factory $data_factory;
27
29 {
30 $this->data_factory = $data_factory;
31 }
32
33 public function getHash(): string
34 {
35 return hash(
36 "sha256",
37 get_class($this)
38 );
39 }
40
41 public function getLabel(): string
42 {
43 return "No major version is skipped in update.";
44 }
45
46 public function isNotable(): bool
47 {
48 return true;
49 }
50
51 public function getPreconditions(Setup\Environment $environment): array
52 {
53 return [
55 ];
56 }
57
58 public function achieve(Setup\Environment $environment): Setup\Environment
59 {
60 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
61 $settings = $factory->settingsFor("common");
62
63 $current_version_string = $settings->get(ilVersionWrittenToSettingsObjective::ILIAS_VERSION_KEY);
64 $current_version = $this->data_factory->version($current_version_string);
65 $target_version = $this->data_factory->version(ILIAS_VERSION_NUMERIC);
66
67 if (($target_version->getMajor() - $current_version->getMajor()) > 1) {
69 "Updates may only be performed from one major version to the " .
70 "next, no major versions may be skipped."
71 );
72 }
73
74 return $environment;
75 }
76
77 public function isApplicable(Setup\Environment $environment): bool
78 {
79 return true;
80 }
81}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Signals that the setup is not executable at all.
const ILIAS_VERSION_NUMERIC
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...