ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
LOMStructureInitiator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Generator;
31
33{
34 public function __construct(
35 protected ReaderFactoryInterface $reader_factory,
36 protected StructureFactory $structure_factory
37 ) {
38 }
39
40 public function set(): StructureSetInterface
41 {
42 return $this->structure_factory->set(
43 $this->getStructureRoot()
44 );
45 }
46
48 {
49 $reader = $this->reader_factory->reader();
50 return $this->structure_factory->root(
51 $reader->definition(),
52 ...$this->getSubElements(0, ...$reader->subDefinitions())
53 );
54 }
55
60 protected function getSubElements(
61 int $depth,
62 ReaderInterface ...$readers
63 ): Generator {
64 if ($depth > 20) {
65 throw new ilMDStructureException('LOM Structure is nested to deep.');
66 }
67 foreach ($readers as $reader) {
68 yield $this->structure_factory->structure(
69 $reader->definition(),
70 ...$this->getSubElements($depth + 1, ...$reader->subDefinitions())
71 );
72 }
73 }
74}
getSubElements(int $depth, ReaderInterface ... $readers)
__construct(protected ReaderFactoryInterface $reader_factory, protected StructureFactory $structure_factory)
if(!file_exists('../ilias.ini.php'))