ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
LOMDictionaryInitiator.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 
29 class LOMDictionaryInitiator extends BaseDictionaryInitiator
30 {
31  protected const string MD_SCHEMA = 'LOMv1.0';
32 
34 
35  public function __construct(
36  TagFactory $tag_factory,
40  ) {
41  $this->tag_factory = $tag_factory;
42  parent::__construct($path_factory, $navigator_factory, $structure);
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(
127  StructureElementInterface $element,
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(
147  StructureElementInterface $element,
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 }
addTag(StructureElementInterface $element, Restriction $restriction, ?int $index=null)
addPresetValueTag(StructureElementInterface $element, string $value, int $index)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getRoot()
Returns the root element of the metadata set.
__construct(TagFactory $tag_factory, PathFactoryInterface $path_factory, NavigatorFactoryInterface $navigator_factory, StructureSetInterface $structure)
$general
SECTIONS.
addTagToElement(TagInterface $tag, StructureElementInterface $element)
When indices are added, the tag applies only to copies of the element with those indices (beginning w...
NavigatorFactoryInterface $navigator_factory
only needed to instantiate dictionaries, which is done in inheritors
__construct(Container $dic, ilPlugin $plugin)