19declare(strict_types=1);
73 throw new \LogicException(
74 "You may only mark objectives as failed that have been returned by this iterator."
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 === []) {
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;
Tries to enumerate all preconditions for the given objective, where the ones that can be achieved (i....
setEnvironment(Environment $environment)
markAsFailed(Objective $objective)
array $reverse_dependencies
setReverseDependency(string $other, string $cur)
detectDependencyCycles(string $cur, string $next)
__construct(Environment $environment, Objective $objective)
A wrapper around an objective that attempts to achieve the wrapped objective but won't stop the proce...
Signals that some goal won't be achievable by actions of the system ever.
An environment holds resources to be used in the setup process.
An objective is a desired state of the system that is supposed to be created by the setup.
getHash()
Get a hash for this objective.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.