ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ObjectiveWithPreconditions.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Setup\Objective;
22 
23 use ILIAS\Setup;
24 
32 {
34 
38  protected array $preconditions;
39 
40  public function __construct(Setup\Objective $original, Setup\Objective ...$preconditions)
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(),
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 }
An objective is a desired state of the system that is supposed to be created by the setup...
Definition: Objective.php:30
A wrapper around an objective that adds some preconditions.
__construct(Setup\Objective $original, Setup\Objective ... $preconditions)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Definition: Environment.php:27