19 declare(strict_types=1);
53 ElementFactory $element_factory,
72 return $this->element_factory->set(
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.');
103 $name = $sub->getDefinition()->name();
104 if ($sub->isScaffold()) {
107 if ($sub->getDefinition()->unique() && in_array($name, $sub_names)) {
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(),
118 ...$this->getFinishedAndCleanSubElements($sub, $depth + 1)
122 $message = $sub->getData()->value() .
' is not valid as ' .
123 $sub->getData()->type()->value .
' data.';
131 $element->
getDefinition()->dataType() !== Type::VOCAB_VALUE &&
134 return SlotIdentifier::NULL;
136 return $this->element_vocab_helper->slotForElement($element);
151 bool $replace_by_neutral,
155 throw new \ilMDStructureException(
'LOM Structure is nested to deep.');
162 $marker->action() === Action::CREATE_OR_UPDATE &&
163 !$this->data_validator->isValid($element,
false)
165 $message = $marker->dataValue() .
' is not valid as ' .
168 $element->
mark($this->marker_factory, Action::NEUTRAL);
170 foreach ($this->dictionary->tagsForElement($element) as $tag) {
182 bool $replace_by_neutral
185 case Restriction::PRESET_VALUE:
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 237 $message = $super->getDefinition()->name() .
': ' .
$message;
240 throw new \ilMDRepositoryException(
'Invalid marker on element ' . $message);
242 $this->
logger->info(
'Skipping element ' . $message);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins