ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
LOMDictionaryInitiator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\MetaData\Paths\FactoryInterface as PathFactoryInterface;
28
29class LOMDictionaryInitiator extends BaseDictionaryInitiator
30{
31 protected const string MD_SCHEMA = 'LOMv1.0';
32
34
35 public function __construct(
37 PathFactoryInterface $path_factory,
40 ) {
41 $this->tag_factory = $tag_factory;
43 }
44
45 public function get(): DictionaryInterface
46 {
47 $this->initDictionary();
48 return new LOMDictionary($this->path_factory, $this->navigator_factory, ...$this->getTagAssignments());
49 }
50
51 protected function initDictionary(): void
52 {
53 $structure = $this->getStructure();
54
55 $this->addTag($structure->getRoot(), Restriction::NOT_DELETABLE);
56
59 }
60
61 protected function setTagsForGeneral(
63 ): void {
64 $this->addTag(
65 $general = $structure->getRoot()->getSubElement('general'),
66 Restriction::NOT_DELETABLE
67 );
68 $this->addTag(
69 $title = $general->getSubElement('title'),
70 Restriction::NOT_DELETABLE
71 );
72 $this->addTag(
73 $title->getSubElement('string'),
74 Restriction::NOT_DELETABLE
75 );
76 $this->addTag(
77 $identifier = $general->getSubElement('identifier'),
78 Restriction::NOT_DELETABLE,
79 0
80 );
81 $this->addTag(
82 $identifier->getSubElement('catalog'),
83 Restriction::NOT_DELETABLE,
84 0
85 );
86 $this->addTag(
87 $identifier->getSubElement('catalog'),
89 0
90 );
91 $this->addTag(
92 $identifier->getSubElement('entry'),
93 Restriction::NOT_DELETABLE,
94 0
95 );
96 $this->addTag(
97 $identifier->getSubElement('entry'),
99 0
100 );
101 }
102
103 protected function setTagsForMetaMetadata(
105 ): void {
106 $meta_schema = $structure->getRoot()
107 ->getSubElement('metaMetadata')
108 ->getSubElement('metadataSchema');
109 $this->addTag(
110 $meta_schema,
112 0
113 );
114 $this->addTag(
115 $meta_schema,
116 Restriction::NOT_DELETABLE,
117 0
118 );
119 $this->addPresetValueTag(
120 $meta_schema,
121 self::MD_SCHEMA,
122 0
123 );
124 }
125
126 protected function addTag(
128 Restriction $restriction,
129 ?int $index = null
130 ): void {
131 if (is_null($index)) {
132 $tag = $this->tag_factory->tag(
133 $restriction,
134 ''
135 );
136 } else {
137 $tag = $this->tag_factory->tag(
138 $restriction,
139 '',
140 $index
141 );
142 }
143 $this->addTagToElement($tag, $element);
144 }
145
146 protected function addPresetValueTag(
148 string $value,
149 int $index
150 ): void {
151 $tag = $this->tag_factory->tag(
152 Restriction::PRESET_VALUE,
153 $value,
154 $index
155 );
156 $this->addTagToElement($tag, $element);
157 }
158}
$general
SECTIONS.
$structure
TOTAL STRUCTURE.
__construct(TagFactory $tag_factory, PathFactoryInterface $path_factory, NavigatorFactoryInterface $navigator_factory, StructureSetInterface $structure)
addTag(StructureElementInterface $element, Restriction $restriction, ?int $index=null)
addPresetValueTag(StructureElementInterface $element, string $value, int $index)
NavigatorFactoryInterface $navigator_factory
only needed to instantiate dictionaries, which is done in inheritors
getRoot()
Returns the root element of the metadata set.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))