19 declare(strict_types=1);
73 bool $add_as_first =
false 91 bool $add_as_first =
false 94 foreach ($next_step->
filters() as $filter) {
95 $builder = $builder->withAdditionalFilterAtCurrentStep(
107 if (!isset($this->current_step_name)) {
108 throw new \ilMDPathException(
109 'Cannot add filter because there is no current step.' 112 $clone = clone $this;
113 $clone->current_step_filters[] =
new Filter(
128 $clone->leads_to_one,
132 if (!
$path->isRelative()) {
143 $element = $this->structure->getRoot();
144 foreach ($path->
steps() as $step) {
145 $name = $step->name();
147 $element = $element->getSuperElement();
149 $element = $element->getSubElement($name);
151 if (is_null($element)) {
152 $name = is_string($name) ? $name : $name->value;
153 throw new \ilMDPathException(
154 "In the path '" . $path->
toString() .
"', the step '" . $name .
"' is invalid." 162 bool $add_as_first =
false 165 $clone->current_step_name = $name;
166 $clone->current_add_as_first = $add_as_first;
172 $clone = clone $this;
173 if (!isset($clone->current_step_name)) {
177 $new_step =
new Step(
178 $clone->current_step_name,
179 ...$clone->current_step_filters
181 if ($clone->current_add_as_first) {
182 array_unshift($clone->steps, $new_step);
184 $clone->steps[] = $new_step;
187 $clone->current_step_name = null;
188 $clone->current_step_filters = [];
189 $clone->current_add_as_first =
false;