ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
CallableObjective.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
16{
20 protected $callable;
21
25 protected $label;
26
30 protected $is_notable;
31
35 protected $preconditions;
36
37 public function __construct(callable $callable, string $label, bool $is_notable, Objective ...$preconditions)
38 {
39 $this->callable = $callable;
40 $this->label = $label;
41 $this->is_notable = $is_notable;
42 $this->preconditions = $preconditions;
43 }
44
48 public function getHash() : string
49 {
50 return hash(
51 "sha256",
52 spl_object_hash($this)
53 );
54 }
55
59 public function getLabel() : string
60 {
61 return $this->label;
62 }
63
67 public function isNotable() : bool
68 {
69 return $this->is_notable;
70 }
71
75 public function getPreconditions(Environment $environment) : array
76 {
78 }
79
83 public function achieve(Environment $environment) : Environment
84 {
85 $res = call_user_func($this->callable, $environment);
86 if ($res instanceof Environment) {
87 return $res;
88 }
89 return $environment;
90 }
91}
An exception for terminatinating execution or to throw for unit testing.
A callable objective wraps a callable into an objective.
__construct(callable $callable, string $label, bool $is_notable, Objective ... $preconditions)
achieve(Environment $environment)
@inheritdocs
getPreconditions(Environment $environment)
@inheritdocs
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:15
foreach($_POST as $key=> $value) $res