ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Builder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\MetaData\Paths\BuilderInterface as InternalBuilderInterface;
26
27class Builder implements BuilderInterface
28{
29 protected InternalBuilderInterface $internal_builder;
30
31 public function __construct(InternalBuilderInterface $internal_builder)
32 {
33 $internal_builder->withRelative(false)
34 ->withLeadsToExactlyOneElement(false);
35 $this->internal_builder = $internal_builder;
36 }
37
38 public function withNextStep(string $name): BuilderInterface
39 {
40 $clone = clone $this;
41 $clone->internal_builder = $clone->internal_builder->withNextStep($name);
42 return $clone;
43 }
44
46 {
47 $clone = clone $this;
48 $clone->internal_builder = $clone->internal_builder->withNextStepToSuperElement();
49 return $clone;
50 }
51
56 FilterType $type,
57 string ...$values
59 $clone = clone $this;
60 try {
61 $clone->internal_builder = $clone->internal_builder->withAdditionalFilterAtCurrentStep(
62 $type,
63 ...$values
64 );
65 } catch (\ilMDPathException $e) {
66 throw new \ilMDServicesException($e->getMessage());
67 }
68
69 return $clone;
70 }
71
75 public function get(): PathInterface
76 {
77 try {
78 return $this->internal_builder->get();
79 } catch (\ilMDPathException $e) {
80 throw new \ilMDServicesException($e->getMessage());
81 }
82
83 }
84}
__construct(InternalBuilderInterface $internal_builder)
Definition: Builder.php:31
InternalBuilderInterface $internal_builder
Definition: Builder.php:29
withAdditionalFilterAtCurrentStep(FilterType $type, string ... $values)
Definition: Builder.php:55
withNextStepToSuperElement(bool $add_as_first=false)
Add going to the super element as the next step to the path.
withAdditionalFilterAtCurrentStep(FilterType $type, string ... $values)
Adds a filter to the current step, restricting what elements are included in it:
withNextStep(string $name, bool $add_as_first=false)
Add the next step to the path.
FilterType
Values should always be all lowercase.
Definition: FilterType.php:27