ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ScaffoldProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\MetaData\Paths\FactoryInterface as PathFactoryInterface;
29
31{
33 protected PathFactoryInterface $path_factory;
36
37 public function __construct(
39 PathFactoryInterface $path_factory,
42 ) {
43 $this->scaffold_factory = $scaffold_factory;
44 $this->path_factory = $path_factory;
45 $this->navigator_factory = $navigator_factory;
46 $this->structure = $structure;
47 }
48
52 public function getScaffoldsForElement(
53 ElementInterface $element
54 ): \Generator {
55 $sub_names = [];
56 foreach ($element->getSubElements() as $sub) {
57 $sub_names[] = $sub->getDefinition()->name();
58 }
59
60 foreach ($this->getPossibleSubElementDefinitionsForElementInOrder($element) as $sub_definition) {
61 if (
62 !$sub_definition->unique() ||
63 !in_array($sub_definition->name(), $sub_names)
64 ) {
65 yield $this->scaffold_factory->scaffold($sub_definition);
66 }
67 }
68 }
69
74 ElementInterface $element
75 ): \Generator {
76 foreach ($this->getPossibleSubElementDefinitionsForElementInOrder($element) as $sub_definition) {
77 yield $sub_definition->name();
78 }
79 }
80
82 ElementInterface $element
83 ): \Generator {
84 $navigator = $this->navigator_factory->structureNavigator(
85 $this->path_factory->toElement($element),
86 $this->structure->getRoot()
87 );
88 $structure_element = $navigator->elementAtFinalStep();
89
90 foreach ($structure_element->getSubElements() as $sub) {
91 yield $sub->getDefinition();
92 }
93 }
94
95 public function set(): SetInterface
96 {
97 return $this->scaffold_factory->set($this->structure->getRoot()->getDefinition());
98 }
99}
__construct(ScaffoldFactoryInterface $scaffold_factory, PathFactoryInterface $path_factory, NavigatorFactoryInterface $navigator_factory, StructureSetInterface $structure,)