19declare(strict_types=1);
72 return $this->element_factory->set(
74 $this->getCleanRoot($set)
81 $root = $set->getRoot();
82 if (!$this->data_validator->isValid($root,
true)) {
83 throw new \ilMDRepositoryException(
'Invalid data on root');
85 return $this->element_factory->root(
86 $root->getDefinition(),
87 ...$this->getFinishedAndCleanSubElements($root, 0)
99 throw new \ilMDStructureException(
'LOM Structure is nested to deep.');
102 foreach ($element->getSubElements() as $sub) {
103 $name = $sub->getDefinition()->name();
104 if ($sub->isScaffold()) {
107 if ($sub->getDefinition()->unique() && in_array($name, $sub_names)) {
108 $this->throwErrorOrLog($sub,
'duplicate of unique element.');
111 if ($this->data_validator->isValid($sub,
true)) {
112 $sub_names[] = $name;
113 yield $this->element_factory->element(
115 $sub->getDefinition(),
116 $sub->getData()->value(),
117 $this->lookUpVocabSlotForElement($sub),
118 ...$this->getFinishedAndCleanSubElements($sub, $depth + 1)
122 $message = $sub->getData()->value() .
' is not valid as ' .
123 $sub->getData()->type()->value .
' data.';
124 $this->throwErrorOrLog($sub,
$message);
131 $element->
getDefinition()->dataType() !== Type::VOCAB_VALUE &&
136 return $this->element_vocab_helper->slotForElement($element);
141 $this->checkMarkerOnElement($set->
getRoot(),
true, 0);
146 $this->checkMarkerOnElement($set->
getRoot(),
false, 0);
151 bool $replace_by_neutral,
155 throw new \ilMDStructureException(
'LOM Structure is nested to deep.');
160 $marker = $element->getMarker();
162 $marker->action() === Action::CREATE_OR_UPDATE &&
163 !$this->data_validator->isValid($element,
false)
165 $message = $marker->dataValue() .
' is not valid as ' .
166 $element->getDefinition()->dataType()->value .
' data.';
167 $this->throwErrorOrLog($element,
$message, !$replace_by_neutral);
168 $element->mark($this->marker_factory, Action::NEUTRAL);
170 foreach ($this->dictionary->tagsForElement($element) as $tag) {
171 $this->checkMarkerAgainstTag($tag, $element, $marker, $replace_by_neutral);
173 foreach ($element->getSubElements() as $sub) {
174 $this->checkMarkerOnElement($sub, $replace_by_neutral, $depth + 1);
182 bool $replace_by_neutral
184 switch ($tag->restriction()) {
185 case Restriction::PRESET_VALUE:
187 $this->willBeCreated($element, $marker) &&
190 $this->throwErrorOrLog(
192 'can only be created with preset value ' . $tag->
value(),
195 $element->
mark($this->marker_factory, Action::NEUTRAL);
199 case Restriction::NOT_DELETABLE:
201 $this->throwErrorOrLog($element,
'cannot be deleted.', !$replace_by_neutral);
202 $element->
mark($this->marker_factory, Action::NEUTRAL);
208 $marker->
action() === Action::CREATE_OR_UPDATE &&
209 $element->
getMDID() !== NoID::SCAFFOLD
211 $this->throwErrorOrLog($element,
'cannot be edited.', !$replace_by_neutral);
212 $element->
mark($this->marker_factory, Action::NEUTRAL);
222 return $element->getMDID() ===
NoID::SCAFFOLD && (
223 $marker->action() ===
Action::CREATE_OR_UPDATE ||
224 $marker->action() ===
Action::NEUTRAL
231 bool $throw_error =
false
233 $id = $element->getMDID();
240 throw new \ilMDRepositoryException(
'Invalid marker on element ' .
$message);
242 $this->
logger->info(
'Skipping element ' . $message);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Component logger with individual log levels by component id.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))