ILIAS  release_7 Revision v7.30-3-g800a261c036
ExternalConditionObjective.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
8
17{
21 protected $label;
22
26 protected $condition;
27
31 protected $message;
32
36 public function __construct(string $label, callable $condition, string $message = null)
37 {
38 $this->condition = $condition;
39 $this->label = $label;
40 $this->message = $message;
41 }
42
46 public function getHash() : string
47 {
48 return hash(
49 "sha256",
50 get_class($this) . "::" . $this->label
51 );
52 }
53
57 public function getLabel() : string
58 {
59 return $this->label;
60 }
61
65 public function isNotable() : bool
66 {
67 return true;
68 }
69
73 public function getPreconditions(Setup\Environment $environment) : array
74 {
75 return [];
76 }
77
81 public function achieve(Setup\Environment $environment) : Setup\Environment
82 {
83 if (($this->condition)($environment)) {
84 return $environment;
85 }
86
87 if ($this->message) {
88 $admin_interaction = $environment->getResource(Setup\Environment::RESOURCE_ADMIN_INTERACTION);
89 $admin_interaction->inform($this->message);
90 }
91
93 "An external condition was not met: {$this->label}"
94 );
95 }
96
100 public function isApplicable(Setup\Environment $environment) : bool
101 {
102 return true;
103 }
104}
An exception for terminatinating execution or to throw for unit testing.
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.
__construct(string $label, callable $condition, string $message=null)
isNotable()
Get to know if this is an interesting objective for a human.
isApplicable(Setup\Environment $environment)
@inheritDoc
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:12
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:15
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...