ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
LOMStructureInitiator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27use ILIAS\MetaData\Paths\FactoryInterface as PathFactoryInterface;
33
35{
38
39 public function __construct(
42 ) {
43 $this->reader_factory = $reader_factory;
44 $this->structure_factory = $structure_factory;
45 }
46
47 public function set(): StructureSetInterface
48 {
49 return $this->structure_factory->set(
50 $this->getStructureRoot()
51 );
52 }
53
55 {
56 $reader = $this->reader_factory->reader();
57 return $this->structure_factory->root(
58 $reader->definition(),
59 ...$this->getSubElements(0, ...$reader->subDefinitions())
60 );
61 }
62
66 protected function getSubElements(
67 int $depth,
68 ReaderInterface ...$readers
69 ): \Generator {
70 if ($depth > 20) {
71 throw new \ilMDStructureException('LOM Structure is nested to deep.');
72 }
73 foreach ($readers as $reader) {
74 yield $this->structure_factory->structure(
75 $reader->definition(),
76 ...$this->getSubElements($depth + 1, ...$reader->subDefinitions())
77 );
78 }
79 }
80}
getSubElements(int $depth, ReaderInterface ... $readers)
__construct(ReaderFactoryInterface $reader_factory, StructureFactory $structure_factory)
if(!file_exists('../ilias.ini.php'))