ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
AdminConfirmedObjective.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
5namespace ILIAS\Setup;
6
7use ILIAS\UI;
8
13{
17 protected $message;
18
19 public function __construct(string $message)
20 {
21 $this->message = $message;
22 }
23
27 public function getHash() : string
28 {
29 return hash(
30 "sha256",
31 get_class($this) . "::" . $this->message
32 );
33 }
34
38 public function getLabel() : string
39 {
40 return "Get a confirmation from admin.";
41 }
42
46 public function isNotable() : bool
47 {
48 return false;
49 }
50
54 public function getPreconditions(Environment $environment) : array
55 {
56 return [];
57 }
58
62 public function achieve(Environment $environment) : Environment
63 {
64 $admin_interaction = $environment->getResource(Environment::RESOURCE_ADMIN_INTERACTION);
65 $achievement_tracker = $environment->getResource(Environment::RESOURCE_ACHIEVEMENT_TRACKER);
66
67 if ($achievement_tracker->isAchieved($this)) {
68 return $environment;
69 }
70
71 if (!$admin_interaction->confirmOrDeny($this->message)) {
73 $this->message
74 );
75 }
76
77 $achievement_tracker->trackAchievementOf($this);
78
79 return $environment;
80 }
81}
An exception for terminatinating execution or to throw for unit testing.
An admin needs to confirm something to achieve this objective.
achieve(Environment $environment)
Objectives can be achieved.They might add resources to the environment when they have been achieved....
isNotable()
Get to know if this is an interesting objective for a human.
getLabel()
Get a label that describes this objective.
getHash()
Get a hash for this objective.The hash of two objectives must be the same, if they are the same objec...
getPreconditions(Environment $environment)
Objectives might depend on other objectives.Objective[]
Signals that a necessary confirmation from the admin is missing.
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