3 declare(strict_types=1);
72 if (!isset($this->returned[$objective->
getHash()])) {
73 throw new \LogicException(
74 "You may only mark objectives as failed that have been returned by this iterator." 78 $this->failed[$objective->
getHash()] =
true;
87 $this->reverse_dependencies = [];
94 throw new \LogicException(
95 "Iterator is finished or wasn't initialized correctly internally." 101 public function key(): string
103 return $this->
current()->getHash();
108 if ($this->stack === []) {
113 $cur = array_pop($this->stack);
114 $hash = $cur->getHash();
116 if (isset($this->returned[$hash]) || isset($this->failed[$hash])) {
122 $failed_preconditions = [];
123 foreach ($cur->getPreconditions($this->environment) as $p) {
125 if (!isset($this->returned[$h]) || isset($this->failed[$h])) {
126 $preconditions[] = $p;
129 if (isset($this->failed[$h])) {
130 $failed_preconditions[] = $p;
136 $preconditions !== [] &&
137 count($preconditions) === count($failed_preconditions)
139 $this->returned[$hash] =
true;
141 if ($this->stack === []) {
144 if ($cur instanceof
Objective\Tentatively) {
148 "Objective '" . $cur->getLabel() .
"' had failed preconditions:\n - " .
149 implode(
"\n - ", array_map(fn ($o) => $o->getLabel(), $failed_preconditions))
157 if ($preconditions === []) {
158 $this->returned[$hash] =
true;
163 $this->stack[] = $cur;
165 foreach (array_reverse($preconditions) as $p) {
174 return $this->
current !== null;
179 if (!isset($this->reverse_dependencies[$next])) {
182 if (in_array($cur, $this->reverse_dependencies[$next])) {
184 "The objectives contain a dependency cycle and won't all be achievable." 187 foreach ($this->reverse_dependencies[$next] as
$d) {
194 if (!isset($this->reverse_dependencies[$other])) {
195 $this->reverse_dependencies[$other] = [];
197 $this->reverse_dependencies[$other][] = $cur;
An objective is a desired state of the system that is supposed to be created by the setup...
setReverseDependency(string $other, string $cur)
Class ChatMainBarProvider .
getHash()
Get a hash for this objective.
__construct(Environment $environment, Objective $objective)
Signals that some goal won't be achievable by actions of the system ever.
markAsFailed(Objective $objective)
detectDependencyCycles(string $cur, string $next)
setEnvironment(Environment $environment)
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.
Tries to enumerate all preconditions for the given objective, where the ones that can be achieved (i...
array $reverse_dependencies