ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ObjectiveWithPreconditions.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{
34
38 protected array $preconditions;
39
41 {
42 if ($preconditions === []) {
43 throw new \InvalidArgumentException(
44 "Expected at least one precondition."
45 );
46 }
47 $this->original = $original;
48 $this->preconditions = $preconditions;
49 }
50
54 public function getHash(): string
55 {
56 return hash(
57 "sha256",
58 self::class
59 . $this->original->getHash()
60 . implode(
61 "",
62 array_map(
63 fn ($o) => $o->getHash(),
64 $this->preconditions
65 )
66 )
67 );
68 }
69
73 public function getLabel(): string
74 {
75 return $this->original->getLabel();
76 }
77
81 public function isNotable(): bool
82 {
83 return $this->original->isNotable();
84 }
85
89 public function getPreconditions(Setup\Environment $environment): array
90 {
91 return array_merge($this->preconditions, $this->original->getPreconditions($environment));
92 }
93
97 public function achieve(Setup\Environment $environment): Setup\Environment
98 {
99 return $this->original->achieve($environment);
100 }
101
105 public function isApplicable(Setup\Environment $environment): bool
106 {
107 return $this->original->isApplicable($environment);
108 }
109}
A wrapper around an objective that adds some preconditions.
getPreconditions(Setup\Environment $environment)
@inheritdocs
isApplicable(Setup\Environment $environment)
@inheritDoc
achieve(Setup\Environment $environment)
@inheritdocs
__construct(Setup\Objective $original, 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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...