ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ObjectiveWithPreconditions.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 
5 namespace ILIAS\Setup\Objective;
6 
7 use ILIAS\Setup;
8 
16 {
20  protected $original;
21 
25  protected $preconditions;
26 
27  public function __construct(Setup\Objective $original, Setup\Objective ...$preconditions)
28  {
29  if (count($preconditions) === 0) {
30  throw new \InvalidArgumentException(
31  "Expected at least one precondition."
32  );
33  }
34  $this->original = $original;
35  $this->preconditions = $preconditions;
36  }
37 
41  public function getHash() : string
42  {
43  return hash(
44  "sha256",
45  self::class
46  . $this->original->getHash()
47  . implode(
48  "",
49  array_map(
50  function ($o) { return $o->getHash(); },
52  )
53  )
54  );
55  }
56 
60  public function getLabel() : string
61  {
62  return $this->original->getLabel();
63  }
64 
68  public function isNotable() : bool
69  {
70  return $this->original->isNotable();
71  }
72 
76  public function getPreconditions(Setup\Environment $environment) : array
77  {
78  return array_merge($this->preconditions, $this->original->getPreconditions($environment));
79  }
80 
84  public function achieve(Setup\Environment $environment) : Setup\Environment
85  {
86  return $this->original->achieve($environment);
87  }
88 
92  public function isApplicable(Setup\Environment $environment) : bool
93  {
94  return $this->original->isApplicable($environment);
95  }
96 }
An objective is a desired state of the system that is supposed to be created by the setup...
Definition: Objective.php:14
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...
An environment holds resources to be used in the setup process.
Definition: Environment.php:11