ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ILIAS\MetaData\Paths\Builder Class Reference
+ Inheritance diagram for ILIAS\MetaData\Paths\Builder:
+ Collaboration diagram for ILIAS\MetaData\Paths\Builder:

Public Member Functions

 __construct (StructureSetInterface $structure)
 
 withRelative (bool $is_relative)
 Relative paths start at some otherwise determined element, absolute paths start at root. More...
 
 withLeadsToExactlyOneElement (bool $leads_to_one)
 Building a path that is flagged to lead to exactly one element, but does not actually do so can throw errors later on. More...
 
 withNextStep (string $name, bool $add_as_first=false)
 Add the next step to the path. More...
 
 withNextStepToSuperElement (bool $add_as_first=false)
 Add going to the super element as the next step to the path. More...
 
 withNextStepFromStep (StepInterface $next_step, bool $add_as_first=false)
 
 withAdditionalFilterAtCurrentStep (FilterType $type, string ... $values)
 
 get ()
 

Protected Member Functions

 validatePathFromRoot (PathInterface $path)
 
 withNextStepFromName (string|StepToken $name, bool $add_as_first=false)
 
 withCurrentStepSaved ()
 

Protected Attributes

StructureSetInterface $structure
 
array $steps = []
 
string StepToken null $current_step_name = null
 
array $current_step_filters = []
 
bool $current_add_as_first = false
 
bool $is_relative = false
 
bool $leads_to_one = false
 

Detailed Description

Definition at line 31 of file Builder.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MetaData\Paths\Builder::__construct ( StructureSetInterface  $structure)

Definition at line 35 of file Builder.php.

References ILIAS\MetaData\Paths\Builder\$structure.

36  {
37  $this->structure = $structure;
38  }
StructureSetInterface $structure
Definition: Builder.php:33

Member Function Documentation

◆ get()

ILIAS\MetaData\Paths\Builder::get ( )
Exceptions

Implements ILIAS\MetaData\Paths\BuilderInterface.

Definition at line 126 of file Builder.php.

References $path, ILIAS\MetaData\Paths\Builder\validatePathFromRoot(), and ILIAS\MetaData\Paths\Builder\withCurrentStepSaved().

126  : PathInterface
127  {
128  $clone = $this->withCurrentStepSaved();
129  $path = new Path(
130  $clone->is_relative,
131  $clone->leads_to_one,
132  ...$clone->steps
133  );
134 
135  if (!$path->isRelative()) {
136  $this->validatePathFromRoot($path);
137  }
138  return $path;
139  }
$path
Definition: ltiservices.php:29
validatePathFromRoot(PathInterface $path)
Definition: Builder.php:144
+ Here is the call graph for this function:

◆ validatePathFromRoot()

ILIAS\MetaData\Paths\Builder::validatePathFromRoot ( PathInterface  $path)
protected
Exceptions

Definition at line 144 of file Builder.php.

References ILIAS\MetaData\Paths\PathInterface\steps(), ILIAS\MetaData\Paths\Steps\SUPER, and ILIAS\MetaData\Paths\PathInterface\toString().

Referenced by ILIAS\MetaData\Paths\Builder\get().

144  : void
145  {
146  $element = $this->structure->getRoot();
147  foreach ($path->steps() as $step) {
148  $name = $step->name();
149  if ($name === StepToken::SUPER) {
150  $element = $element->getSuperElement();
151  } else {
152  $element = $element->getSubElement($name);
153  }
154  if (is_null($element)) {
155  $name = is_string($name) ? $name : $name->value;
156  throw new \ilMDPathException(
157  "In the path '" . $path->toString() . "', the step '" . $name . "' is invalid."
158  );
159  }
160  }
161  }
$path
Definition: ltiservices.php:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withAdditionalFilterAtCurrentStep()

ILIAS\MetaData\Paths\Builder::withAdditionalFilterAtCurrentStep ( FilterType  $type,
string ...  $values 
)
Exceptions

Implements ILIAS\MetaData\Paths\BuilderInterface.

Definition at line 106 of file Builder.php.

109  : BuilderInterface {
110  if (!isset($this->current_step_name)) {
111  throw new \ilMDPathException(
112  'Cannot add filter because there is no current step.'
113  );
114  }
115  $clone = clone $this;
116  $clone->current_step_filters[] = new Filter(
117  $type,
118  ...$values
119  );
120  return $clone;
121  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ withCurrentStepSaved()

ILIAS\MetaData\Paths\Builder::withCurrentStepSaved ( )
protected

Definition at line 173 of file Builder.php.

References null.

Referenced by ILIAS\MetaData\Paths\Builder\get(), and ILIAS\MetaData\Paths\Builder\withNextStepFromName().

173  : Builder
174  {
175  $clone = clone $this;
176  if (!isset($clone->current_step_name)) {
177  return $clone;
178  }
179 
180  $new_step = new Step(
181  $clone->current_step_name,
182  ...$clone->current_step_filters
183  );
184  if ($clone->current_add_as_first) {
185  array_unshift($clone->steps, $new_step);
186  } else {
187  $clone->steps[] = $new_step;
188  }
189 
190  $clone->current_step_name = null;
191  $clone->current_step_filters = [];
192  $clone->current_add_as_first = false;
193 
194  return $clone;
195  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ withLeadsToExactlyOneElement()

ILIAS\MetaData\Paths\Builder::withLeadsToExactlyOneElement ( bool  $leads_to_one)

Building a path that is flagged to lead to exactly one element, but does not actually do so can throw errors later on.

If you set this flag, be sure to set filters correctly. Default is false.

Implements ILIAS\MetaData\Paths\BuilderInterface.

Definition at line 63 of file Builder.php.

References ILIAS\MetaData\Paths\Builder\$leads_to_one.

65  : BuilderInterface {
66  $clone = clone $this;
67  $clone->leads_to_one = $leads_to_one;
68  return $clone;
69  }

◆ withNextStep()

ILIAS\MetaData\Paths\Builder::withNextStep ( string  $name,
bool  $add_as_first = false 
)

Add the next step to the path.

If add_as_first is set true, the step is added as the first and not the last step.

Implements ILIAS\MetaData\Paths\BuilderInterface.

Definition at line 71 of file Builder.php.

References ILIAS\MetaData\Paths\Builder\withNextStepFromName().

74  : BuilderInterface {
75  return $this->withNextStepFromName(
76  $name,
77  $add_as_first
78  );
79  }
withNextStepFromName(string|StepToken $name, bool $add_as_first=false)
Definition: Builder.php:163
+ Here is the call graph for this function:

◆ withNextStepFromName()

ILIAS\MetaData\Paths\Builder::withNextStepFromName ( string|StepToken  $name,
bool  $add_as_first = false 
)
protected

Definition at line 163 of file Builder.php.

References ILIAS\MetaData\Paths\Builder\withCurrentStepSaved().

Referenced by ILIAS\MetaData\Paths\Builder\withNextStep(), ILIAS\MetaData\Paths\Builder\withNextStepFromStep(), and ILIAS\MetaData\Paths\Builder\withNextStepToSuperElement().

166  : BuilderInterface {
167  $clone = $this->withCurrentStepSaved();
168  $clone->current_step_name = $name;
169  $clone->current_add_as_first = $add_as_first;
170  return $clone;
171  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withNextStepFromStep()

ILIAS\MetaData\Paths\Builder::withNextStepFromStep ( StepInterface  $next_step,
bool  $add_as_first = false 
)

Implements ILIAS\MetaData\Paths\BuilderInterface.

Definition at line 89 of file Builder.php.

References ILIAS\MetaData\Paths\Steps\StepInterface\filters(), ILIAS\MetaData\Paths\Steps\StepInterface\name(), and ILIAS\MetaData\Paths\Builder\withNextStepFromName().

92  : BuilderInterface {
93  $builder = $this->withNextStepFromName($next_step->name(), $add_as_first);
94  foreach ($next_step->filters() as $filter) {
95  $builder = $builder->withAdditionalFilterAtCurrentStep(
96  $filter->type(),
97  ...$filter->values()
98  );
99  }
100  return $builder;
101  }
withNextStepFromName(string|StepToken $name, bool $add_as_first=false)
Definition: Builder.php:163
+ Here is the call graph for this function:

◆ withNextStepToSuperElement()

ILIAS\MetaData\Paths\Builder::withNextStepToSuperElement ( bool  $add_as_first = false)

Add going to the super element as the next step to the path.

If add_to_front is set true, the step is added as the first and not the last step.

Implements ILIAS\MetaData\Paths\BuilderInterface.

Definition at line 81 of file Builder.php.

References ILIAS\MetaData\Paths\Steps\SUPER, and ILIAS\MetaData\Paths\Builder\withNextStepFromName().

81  : BuilderInterface
82  {
83  return $this->withNextStepFromName(
85  $add_as_first
86  );
87  }
withNextStepFromName(string|StepToken $name, bool $add_as_first=false)
Definition: Builder.php:163
+ Here is the call graph for this function:

◆ withRelative()

ILIAS\MetaData\Paths\Builder::withRelative ( bool  $is_relative)

Relative paths start at some otherwise determined element, absolute paths start at root.

Default is false.

Implements ILIAS\MetaData\Paths\BuilderInterface.

Definition at line 56 of file Builder.php.

References ILIAS\MetaData\Paths\Builder\$is_relative.

56  : BuilderInterface
57  {
58  $clone = clone $this;
59  $clone->is_relative = $is_relative;
60  return $clone;
61  }

Field Documentation

◆ $current_add_as_first

bool ILIAS\MetaData\Paths\Builder::$current_add_as_first = false
protected

Definition at line 51 of file Builder.php.

◆ $current_step_filters

array ILIAS\MetaData\Paths\Builder::$current_step_filters = []
protected

Definition at line 50 of file Builder.php.

◆ $current_step_name

string StepToken null ILIAS\MetaData\Paths\Builder::$current_step_name = null
protected

Definition at line 45 of file Builder.php.

◆ $is_relative

bool ILIAS\MetaData\Paths\Builder::$is_relative = false
protected

Definition at line 53 of file Builder.php.

Referenced by ILIAS\MetaData\Paths\Builder\withRelative().

◆ $leads_to_one

bool ILIAS\MetaData\Paths\Builder::$leads_to_one = false
protected

◆ $steps

array ILIAS\MetaData\Paths\Builder::$steps = []
protected

Definition at line 43 of file Builder.php.

◆ $structure

StructureSetInterface ILIAS\MetaData\Paths\Builder::$structure
protected

Definition at line 33 of file Builder.php.

Referenced by ILIAS\MetaData\Paths\Builder\__construct().


The documentation for this class was generated from the following file: