ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Builder.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
27 class Builder implements BuilderInterface
28 {
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
58  ): BuilderInterface {
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
FilterType
Values should always be all lowercase.
Definition: FilterType.php:26
InternalBuilderInterface $internal_builder
Definition: Builder.php:29
withNextStep(string $name, bool $add_as_first=false)
Add the next step to the path.
withAdditionalFilterAtCurrentStep(FilterType $type, string ... $values)
Definition: Builder.php:55
withAdditionalFilterAtCurrentStep(FilterType $type, string ... $values)
Adds a filter to the current step, restricting what elements are included in it:
withNextStepToSuperElement(bool $add_as_first=false)
Add going to the super element as the next step to the path.