65 if (!isset($this->returned[$objective->
getHash()])) {
66 throw new \LogicException(
67 "You may only mark objectives as failed that have been returned by this iterator." 71 $this->failed[$objective->
getHash()] =
true;
80 $this->reverse_dependencies = [];
87 throw new \LogicException(
88 "Iterator is finished or wasn't initialized correctly internally." 96 return $this->
current()->getHash();
101 if (count($this->stack) === 0) {
106 $cur = array_pop($this->stack);
107 $hash = $cur->getHash();
109 if (isset($this->returned[$hash]) || isset($this->failed[$hash])) {
115 $failed_preconditions = [];
116 foreach ($cur->getPreconditions($this->environment) as $p) {
118 if (!isset($this->returned[$h]) || isset($this->failed[$h])) {
119 $preconditions[] = $p;
122 if (isset($this->failed[$h])) {
123 $failed_preconditions[] = $p;
129 count($preconditions) !== 0 &&
130 count($preconditions) === count($failed_preconditions)
132 $this->returned[$hash] =
true;
134 if (count($this->stack) === 0) {
136 "Objective '" . $cur->getLabel() .
"' had failed preconditions:\n - " .
137 implode(
"\n - ", array_map(
function ($o) {
138 return $o->getLabel();
139 }, $failed_preconditions))
147 if (count($preconditions) === 0) {
148 $this->returned[$hash] =
true;
153 $this->stack[] = $cur;
155 foreach (array_reverse($preconditions) as $p) {
164 return $this->
current !== null;
169 if (!isset($this->reverse_dependencies[$next])) {
172 if (in_array($cur, $this->reverse_dependencies[$next])) {
174 "The objectives contain a dependency cycle and won't all be achievable." 177 foreach ($this->reverse_dependencies[$next] as
$d) {
184 if (!isset($this->reverse_dependencies[$other])) {
185 $this->reverse_dependencies[$other] = [];
187 $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)
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...
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d