ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CallableObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Setup\Objective;
22
23use ILIAS\Setup;
24
32{
36 protected $callable;
37
38 protected string $label;
39
40 protected bool $is_notable;
41
45 protected array $preconditions;
46
47 public function __construct(callable $callable, string $label, bool $is_notable, Setup\Objective ...$preconditions)
48 {
49 $this->callable = $callable;
50 $this->label = $label;
51 $this->is_notable = $is_notable;
52 $this->preconditions = $preconditions;
53 }
54
55 public function getHash(): string
56 {
57 return hash(
58 "sha256",
59 spl_object_hash($this)
60 );
61 }
62
63 public function getLabel(): string
64 {
65 return $this->label;
66 }
67
68 public function isNotable(): bool
69 {
70 return $this->is_notable;
71 }
72
73 public function getPreconditions(Setup\Environment $environment): array
74 {
76 }
77
78 public function achieve(Setup\Environment $environment): Setup\Environment
79 {
80 $res = call_user_func($this->callable, $environment);
81 if ($res instanceof Setup\Environment) {
82 return $res;
83 }
84 return $environment;
85 }
86
87 public function isApplicable(Setup\Environment $environment): bool
88 {
89 return true;
90 }
91}
A callable objective wraps a callable into an objective.
getHash()
Get a hash for this objective.
getLabel()
Get a label that describes this objective.
isNotable()
Get to know if this is an interesting objective for a human.
getPreconditions(Setup\Environment $environment)
achieve(Setup\Environment $environment)
isApplicable(Setup\Environment $environment)
__construct(callable $callable, string $label, bool $is_notable, Setup\Objective ... $preconditions)
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...