ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ExternalConditionObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Setup\Condition;
22
23use ILIAS\Setup;
24
33{
34 protected string $label;
35 protected \Closure $condition;
36 protected ?string $message;
37 protected bool $block_setup;
38
42 public function __construct(
43 string $label,
44 \Closure $condition,
45 ?string $message = null,
46 bool $block_setup = false
47 ) {
48 $this->condition = $condition;
49 $this->label = $label;
50 $this->message = $message;
51 $this->block_setup = $block_setup;
52 }
53
57 public function getHash(): string
58 {
59 return hash(
60 "sha256",
61 get_class($this) . "::" . $this->label
62 );
63 }
64
68 public function getLabel(): string
69 {
70 return $this->label;
71 }
72
76 public function isNotable(): bool
77 {
78 return true;
79 }
80
84 public function getPreconditions(Setup\Environment $environment): array
85 {
86 return [];
87 }
88
92 public function achieve(Setup\Environment $environment): Setup\Environment
93 {
94 if (($this->condition)($environment)) {
95 return $environment;
96 }
97
98 if ($this->message) {
99 $admin_interaction = $environment->getResource(Setup\Environment::RESOURCE_ADMIN_INTERACTION);
100 $admin_interaction->inform($this->message);
101 }
102 if ($this->block_setup) {
103 throw new Setup\NotExecutableException("An external condition was not met: $this->label");
104 }
105
106 throw new Setup\UnachievableException("An external condition was not met: $this->label");
107 }
108
112 public function isApplicable(Setup\Environment $environment): bool
113 {
114 return true;
115 }
116}
A condition that can't be met by ILIAS itself needs to be met by some external means.
getHash()
Get a hash for this objective.The hash of two objectives must be the same, if they are the same objec...
getLabel()
Get a label that describes this objective.
isNotable()
Get to know if this is an interesting objective for a human.
isApplicable(Setup\Environment $environment)
@inheritDoc
__construct(string $label, \Closure $condition, ?string $message=null, bool $block_setup=false)
Signals that the setup is not executable at all.
Signals that some goal won't be achievable by actions of the system ever.
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...