ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\MetaData\Manipulator\Manipulator Class Reference
+ Inheritance diagram for ILIAS\MetaData\Manipulator\Manipulator:
+ Collaboration diagram for ILIAS\MetaData\Manipulator\Manipulator:

Public Member Functions

 __construct (ScaffoldProviderInterface $scaffold_provider, MarkerFactoryInterface $marker_factory, NavigatorFactoryInterface $navigator_factory, PathFactoryInterface $path_factory, PathUtilitiesFactoryInterface $path_utilities_factory)
 
 prepareCreateOrUpdate (SetInterface $set, PathInterface $path, string ... $values)
 
 prepareForceCreate (SetInterface $set, PathInterface $path, string ... $values)
 

Protected Member Functions

 moveNavigatorBackwardsToFirstNonUnique (NavigatorInterface $navigator)
 
 remainingPathOfNavigator (NavigatorInterface $navigator)
 
 getLastNavigatorWithElements (PathInterface $path, ElementInterface $root)
 
 insertPathElementsAsScaffolds (PathInterface $path, ElementInterface $root, PathConditionsCollectionInterface $path_conditions_collection)
 
 createTargetElements (array $roots, array $paths, PathConditionsCollectionInterface $path_conditions)
 
 insertConditionPathElementsAsScaffolds (PathInterface $condition_path, ElementInterface $root)
 
 addAndMarkScaffoldByStep (ElementInterface $element, StepInterface $step)
 also returns the added scaffold, if valid More...
 
 markElementsCreateOrUpdate (array $target_elements, array $values)
 
 markElementsDelete (array $target_elements)
 

Protected Attributes

ScaffoldProviderInterface $scaffold_provider
 
MarkerFactoryInterface $marker_factory
 
NavigatorFactoryInterface $navigator_factory
 
PathFactoryInterface $path_factory
 
PathUtilitiesFactoryInterface $path_utilities_factory
 

Detailed Description

Definition at line 41 of file Manipulator.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MetaData\Manipulator\Manipulator::__construct ( ScaffoldProviderInterface  $scaffold_provider,
MarkerFactoryInterface  $marker_factory,
NavigatorFactoryInterface  $navigator_factory,
PathFactoryInterface  $path_factory,
PathUtilitiesFactoryInterface  $path_utilities_factory 
)

Member Function Documentation

◆ addAndMarkScaffoldByStep()

ILIAS\MetaData\Manipulator\Manipulator::addAndMarkScaffoldByStep ( ElementInterface  $element,
StepInterface  $step 
)
protected

also returns the added scaffold, if valid

Definition at line 397 of file Manipulator.php.

References $data, ILIAS\MetaData\Elements\Scaffolds\ScaffoldableInterface\addScaffoldToSubElements(), ILIAS\MetaData\Paths\Filters\DATA, ILIAS\MetaData\Paths\Steps\StepInterface\filters(), ILIAS\MetaData\Elements\ElementInterface\getSuperElement(), ILIAS\MetaData\Paths\Steps\StepInterface\name(), null, and ILIAS\MetaData\Paths\Steps\SUPER.

Referenced by ILIAS\MetaData\Manipulator\Manipulator\insertConditionPathElementsAsScaffolds(), and ILIAS\MetaData\Manipulator\Manipulator\insertPathElementsAsScaffolds().

400  : ?ElementInterface {
401  if ($step->name() === StepToken::SUPER) {
402  return $element->getSuperElement();
403  }
404  $scaffold = $element->addScaffoldToSubElements(
405  $this->scaffold_provider,
406  $step->name()
407  );
408  if (!isset($scaffold)) {
409  return null;
410  }
411  $data = '';
412  foreach ($step->filters() as $filter) {
413  if ($filter->type() === FilterType::DATA) {
414  $data = $filter->values()->current();
415  break;
416  }
417  }
418  $scaffold->mark(
419  $this->marker_factory,
420  Action::CREATE_OR_UPDATE,
421  $data
422  );
423  return $scaffold;
424  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createTargetElements()

ILIAS\MetaData\Manipulator\Manipulator::createTargetElements ( array  $roots,
array  $paths,
PathConditionsCollectionInterface  $path_conditions 
)
protected
Parameters
ElementInterface[]$roots
PathInterface[]$paths
Returns
ElementInterface[]
Exceptions
ilMDPathException

Definition at line 359 of file Manipulator.php.

References ILIAS\MetaData\Manipulator\Manipulator\insertPathElementsAsScaffolds().

Referenced by ILIAS\MetaData\Manipulator\Manipulator\prepareForceCreate().

363  : array {
364  $target_elements = [];
365  while (0 < count($paths)) {
366  $target_elements[] = $this->insertPathElementsAsScaffolds(
367  array_shift($paths),
368  array_shift($roots),
369  $path_conditions
370  );
371  }
372  return $target_elements;
373  }
insertPathElementsAsScaffolds(PathInterface $path, ElementInterface $root, PathConditionsCollectionInterface $path_conditions_collection)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastNavigatorWithElements()

ILIAS\MetaData\Manipulator\Manipulator::getLastNavigatorWithElements ( PathInterface  $path,
ElementInterface  $root 
)
protected

Definition at line 315 of file Manipulator.php.

References ILIAS\MetaData\Paths\Navigator\NavigatorInterface\nextStep().

Referenced by ILIAS\MetaData\Manipulator\Manipulator\prepareForceCreate().

318  : NavigatorInterface {
319  $navigator = $this->navigator_factory->navigator($path, $root);
320  while ($navigator->hasNextStep() && $navigator->nextStep()->hasElements()) {
321  $navigator = $navigator->nextStep();
322  }
323  return $navigator;
324  }
$path
Definition: ltiservices.php:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertConditionPathElementsAsScaffolds()

ILIAS\MetaData\Manipulator\Manipulator::insertConditionPathElementsAsScaffolds ( PathInterface  $condition_path,
ElementInterface  $root 
)
protected
Exceptions
ilMDPathException

Definition at line 378 of file Manipulator.php.

References ILIAS\MetaData\Manipulator\Manipulator\addAndMarkScaffoldByStep().

Referenced by ILIAS\MetaData\Manipulator\Manipulator\insertPathElementsAsScaffolds().

381  : void {
382  $navigator = $this->navigator_factory->navigator($condition_path, $root);
383  $navigator = $navigator->nextStep();
384  $scaffold = $root;
385  while (!is_null($navigator)) {
386  $scaffold = $this->addAndMarkScaffoldByStep($scaffold, $navigator->currentStep());
387  if (is_null($scaffold)) {
388  throw new ilMDPathException('Cannot create scaffold, invalid path.');
389  }
390  $navigator = $navigator->nextStep();
391  }
392  }
addAndMarkScaffoldByStep(ElementInterface $element, StepInterface $step)
also returns the added scaffold, if valid
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertPathElementsAsScaffolds()

ILIAS\MetaData\Manipulator\Manipulator::insertPathElementsAsScaffolds ( PathInterface  $path,
ElementInterface  $root,
PathConditionsCollectionInterface  $path_conditions_collection 
)
protected
Exceptions
ilMDPathException

Definition at line 329 of file Manipulator.php.

References ILIAS\MetaData\Manipulator\Manipulator\addAndMarkScaffoldByStep(), ILIAS\MetaData\Manipulator\Path\PathConditionsCollectionInterface\getConditionPathByStepName(), and ILIAS\MetaData\Manipulator\Manipulator\insertConditionPathElementsAsScaffolds().

Referenced by ILIAS\MetaData\Manipulator\Manipulator\createTargetElements(), and ILIAS\MetaData\Manipulator\Manipulator\prepareForceCreate().

333  : ElementInterface {
334  $navigator = $this->navigator_factory->navigator($path, $root);
335  $navigator = $navigator->nextStep();
336  $scaffold = $root;
337  while (!is_null($navigator)) {
338  $scaffold = $this->addAndMarkScaffoldByStep($scaffold, $navigator->currentStep());
339  if (is_null($scaffold)) {
340  throw new ilMDPathException(
341  'Cannot create scaffold at step: ' . $navigator->currentStep()->name() . ', invalid path.'
342  );
343  }
344  $condition_path = $path_conditions_collection->getConditionPathByStepName($navigator->currentStep()->name());
345  if ($condition_path->steps()->valid()) {
346  $this->insertConditionPathElementsAsScaffolds($condition_path, $scaffold);
347  }
348  $navigator = $navigator->nextStep();
349  }
350  return $scaffold;
351  }
insertConditionPathElementsAsScaffolds(PathInterface $condition_path, ElementInterface $root)
$path
Definition: ltiservices.php:29
addAndMarkScaffoldByStep(ElementInterface $element, StepInterface $step)
also returns the added scaffold, if valid
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ markElementsCreateOrUpdate()

ILIAS\MetaData\Manipulator\Manipulator::markElementsCreateOrUpdate ( array  $target_elements,
array  $values 
)
protected
Parameters
ElementInterface[]$target_elements
array$values

Definition at line 430 of file Manipulator.php.

References ILIAS\MetaData\Elements\Markers\MarkableInterface\mark().

Referenced by ILIAS\MetaData\Manipulator\Manipulator\prepareCreateOrUpdate(), and ILIAS\MetaData\Manipulator\Manipulator\prepareForceCreate().

430  : void
431  {
432  array_map(function (ElementInterface $element, ?string $value) {
433  $element->mark($this->marker_factory, Action::CREATE_OR_UPDATE, $value);
434  }, $target_elements, $values);
435  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ markElementsDelete()

ILIAS\MetaData\Manipulator\Manipulator::markElementsDelete ( array  $target_elements)
protected

Definition at line 437 of file Manipulator.php.

References ILIAS\MetaData\Elements\Markers\DELETE, and ILIAS\MetaData\Elements\Markers\MarkableInterface\mark().

Referenced by ILIAS\MetaData\Manipulator\Manipulator\__construct().

437  : void
438  {
439  array_map(function (ElementInterface $element) {
440  $element->mark($this->marker_factory, Action::DELETE);
441  }, $target_elements);
442  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ moveNavigatorBackwardsToFirstNonUnique()

ILIAS\MetaData\Manipulator\Manipulator::moveNavigatorBackwardsToFirstNonUnique ( NavigatorInterface  $navigator)
protected
Exceptions
ilMDPathException

Definition at line 291 of file Manipulator.php.

References ILIAS\MetaData\Paths\Navigator\BaseNavigatorInterface\hasPreviousStep(), ILIAS\MetaData\Paths\Navigator\NavigatorInterface\lastElement(), and ILIAS\MetaData\Paths\Navigator\NavigatorInterface\previousStep().

Referenced by ILIAS\MetaData\Manipulator\Manipulator\prepareForceCreate().

291  : NavigatorInterface
292  {
293  while ($navigator->hasPreviousStep() && $navigator->lastElement()->getDefinition()->unique()) {
294  $navigator = $navigator->previousStep();
295  }
296  return $navigator;
297  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareCreateOrUpdate()

ILIAS\MetaData\Manipulator\Manipulator::prepareCreateOrUpdate ( SetInterface  $set,
PathInterface  $path,
string ...  $values 
)
Exceptions
ilMDPathException

Implements ILIAS\MetaData\Manipulator\ManipulatorInterface.

Definition at line 88 of file Manipulator.php.

References $path, and ILIAS\MetaData\Manipulator\Manipulator\markElementsCreateOrUpdate().

92  : SetInterface {
93  $my_set = clone $set;
94  $elements_to_update = $this->getElementsToUpdate($my_set->getRoot(), $path, ...$values);
95  $remaining_values = array_slice($values, 0, count($values) - count($elements_to_update));
96  $elements_to_create = $this->getElementsToCreate($my_set->getRoot(), $path, ...$remaining_values);
97  $target_elements = array_merge($elements_to_update, $elements_to_create);
98  $this->markElementsCreateOrUpdate($target_elements, $values);
99  return $my_set;
100  }
$path
Definition: ltiservices.php:29
markElementsCreateOrUpdate(array $target_elements, array $values)
+ Here is the call graph for this function:

◆ prepareForceCreate()

ILIAS\MetaData\Manipulator\Manipulator::prepareForceCreate ( SetInterface  $set,
PathInterface  $path,
string ...  $values 
)
Exceptions
ilMDPathException

Implements ILIAS\MetaData\Manipulator\ManipulatorInterface.

Definition at line 105 of file Manipulator.php.

References $path, ILIAS\MetaData\Manipulator\Manipulator\createTargetElements(), ILIAS\MetaData\Manipulator\Manipulator\getLastNavigatorWithElements(), ILIAS\MetaData\Manipulator\Manipulator\insertPathElementsAsScaffolds(), ILIAS\MetaData\Manipulator\Manipulator\markElementsCreateOrUpdate(), ILIAS\MetaData\Manipulator\Manipulator\moveNavigatorBackwardsToFirstNonUnique(), and ILIAS\MetaData\Manipulator\Manipulator\remainingPathOfNavigator().

109  : SetInterface {
110  $my_set = clone $set;
111  $target_elements = $this->getElementsToCreate($my_set->getRoot(), $path, ...$values);
112  $this->markElementsCreateOrUpdate($target_elements, $values);
113  return $my_set;
114  }
$path
Definition: ltiservices.php:29
markElementsCreateOrUpdate(array $target_elements, array $values)
+ Here is the call graph for this function:

◆ remainingPathOfNavigator()

ILIAS\MetaData\Manipulator\Manipulator::remainingPathOfNavigator ( NavigatorInterface  $navigator)
protected

Definition at line 299 of file Manipulator.php.

References ILIAS\MetaData\Paths\Navigator\BaseNavigatorInterface\currentStep(), and ILIAS\MetaData\Paths\Navigator\NavigatorInterface\nextStep().

Referenced by ILIAS\MetaData\Manipulator\Manipulator\prepareForceCreate().

299  : PathInterface
300  {
301  $builder = $this->path_factory->custom()
302  ->withRelative(true)
303  ->withLeadsToExactlyOneElement(false);
304  while (!is_null($navigator)) {
305  if (is_null($navigator->currentStep())) {
306  $navigator = $navigator->nextStep();
307  continue;
308  }
309  $builder = $builder->withNextStepFromStep($navigator->currentStep(), false);
310  $navigator = $navigator->nextStep();
311  }
312  return $builder->get();
313  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $marker_factory

MarkerFactoryInterface ILIAS\MetaData\Manipulator\Manipulator::$marker_factory
protected

Definition at line 44 of file Manipulator.php.

Referenced by ILIAS\MetaData\Manipulator\Manipulator\__construct().

◆ $navigator_factory

NavigatorFactoryInterface ILIAS\MetaData\Manipulator\Manipulator::$navigator_factory
protected

Definition at line 45 of file Manipulator.php.

Referenced by ILIAS\MetaData\Manipulator\Manipulator\__construct().

◆ $path_factory

PathFactoryInterface ILIAS\MetaData\Manipulator\Manipulator::$path_factory
protected

Definition at line 46 of file Manipulator.php.

Referenced by ILIAS\MetaData\Manipulator\Manipulator\__construct().

◆ $path_utilities_factory

PathUtilitiesFactoryInterface ILIAS\MetaData\Manipulator\Manipulator::$path_utilities_factory
protected

Definition at line 47 of file Manipulator.php.

Referenced by ILIAS\MetaData\Manipulator\Manipulator\__construct().

◆ $scaffold_provider

ScaffoldProviderInterface ILIAS\MetaData\Manipulator\Manipulator::$scaffold_provider
protected

Definition at line 43 of file Manipulator.php.

Referenced by ILIAS\MetaData\Manipulator\Manipulator\__construct().


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