ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Manipulator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
29{
30 protected InternalManipulator $internal_manipulator;
32 protected SetInterface $set;
33
34 public function __construct(
35 InternalManipulator $internal_manipulator,
38 ) {
39 $this->internal_manipulator = $internal_manipulator;
40 $this->repository = $repository;
41 $this->set = $set;
42 }
43
44 public function prepareCreateOrUpdate(
46 string ...$values
48 try {
49 $set = $this->internal_manipulator->prepareCreateOrUpdate(
50 $this->set,
51 $path,
52 ...$values
53 );
54 } catch (\ilMDPathException $e) {
55 throw new \ilMDServicesException(
56 'Failed to prepare create or update values ' . implode(', ', $values) .
57 ' at "' . $path->toString() . '": ' . $e->getMessage()
58 );
59 }
60
61 return $this->getCloneWithNewSet($set);
62 }
63
64 public function prepareForceCreate(
66 string ...$values
68 try {
69 $set = $this->internal_manipulator->prepareForceCreate(
70 $this->set,
71 $path,
72 ...$values
73 );
74 } catch (\ilMDPathException $e) {
75 throw new \ilMDServicesException(
76 'Failed to force-create values ' . implode(', ', $values) .
77 ' at "' . $path->toString() . '": ' . $e->getMessage()
78 );
79 }
80
81 return $this->getCloneWithNewSet($set);
82 }
83
85 {
86 $set = $this->internal_manipulator->prepareDelete(
87 $this->set,
88 $path
89 );
90 return $this->getCloneWithNewSet($set);
91 }
92
93 public function execute(): void
94 {
95 try {
96 $this->repository->manipulateMD($this->set);
97 } catch (\ilMDRepositoryException $e) {
98 throw new \ilMDServicesException(
99 'Failed to execute manipulations: ' . $e->getMessage()
100 );
101 }
102
103 }
104
106 {
107 $clone = clone $this;
108 $clone->set = $set;
109 return $clone;
110 }
111}
execute()
Execute all prepared actions.
Definition: Manipulator.php:93
prepareForceCreate(PathInterface $path, string ... $values)
New elements are set to be created as specified by the path, and filled with the values.
Definition: Manipulator.php:64
prepareCreateOrUpdate(PathInterface $path, string ... $values)
The values are set to be inserted into the elements specified by the path in order.
Definition: Manipulator.php:44
prepareDelete(PathInterface $path)
All elements specified by the path are set to be deleted.
Definition: Manipulator.php:84
__construct(InternalManipulator $internal_manipulator, RepositoryInterface $repository, SetInterface $set)
Definition: Manipulator.php:34
$path
Definition: ltiservices.php:30
try
handle Lrs Init
Definition: xapiproxy.php:86