69 if (!isset($this->returned[
$objective->getHash()])) {
70 throw new \LogicException(
71 "You may only mark objectives as failed that have been returned by this iterator."
84 $this->reverse_dependencies = [];
91 throw new \LogicException(
92 "Iterator is finished or wasn't initialized correctly internally."
100 return $this->
current()->getHash();
105 if (count($this->stack) === 0) {
110 $cur = array_pop($this->stack);
111 $hash = $cur->getHash();
113 if (isset($this->returned[$hash]) || isset($this->filed[$hash])) {
118 $preconditions = array_filter(
119 $cur->getPreconditions($this->environment),
122 return !isset($this->returned[$h]) || isset($this->failed[$h]);
126 $failed_preconditions = array_filter(
129 return isset($this->failed[$p->getHash()]);
134 if (count($preconditions) !== 0
135 && count($preconditions) === count($failed_preconditions)) {
137 "Objective only has failed preconditions."
142 if (count($preconditions) === 0) {
143 $this->returned[$hash] =
true;
148 $this->stack[] = $cur;
150 foreach (array_reverse($preconditions) as $p) {
159 return $this->
current !==
null;
164 if (!isset($this->reverse_dependencies[$next])) {
167 if (in_array($cur, $this->reverse_dependencies[$next])) {
169 "The objectives contain a dependency cycle and won't all be achievable."
172 foreach ($this->reverse_dependencies[$next] as
$d) {
179 if (!isset($this->reverse_dependencies[$other])) {
180 $this->reverse_dependencies[$other] = [];
182 $this->reverse_dependencies[$other][] = $cur;
An exception for terminatinating execution or to throw for unit testing.
Tries to enumerate all preconditions for the given objective, where the ones that can be achieved (i....
setEnvironment(Environment $environment)
markAsFailed(Objective $objective)
setReverseDependency(string $other, string $cur)
detectDependencyCycles(string $cur, string $next)
__construct(Environment $environment, Objective $objective)
Signals that some goal won't be achievable by actions of the system ever.
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
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.