ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
FullEditor.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\UI\Component\Dropdown\Standard as StandardDropdown;
27use ILIAS\MetaData\Editor\Dictionary\DictionaryInterface as EditorDictionaryInterface;
32use ILIAS\MetaData\Editor\Full\Services\Services as FullEditorServices;
37
39{
40 public const string TABLE = 'table';
41 public const string PANEL = 'panel';
42 public const string ROOT = 'root';
43 public const string FORM = 'form';
44
45 protected EditorDictionaryInterface $editor_dictionary;
47 protected FullEditorServices $services;
52
53 public function __construct(
54 EditorDictionaryInterface $editor_dictionary,
56 FullEditorServices $services,
61 ) {
62 $this->editor_dictionary = $editor_dictionary;
63 $this->navigator_factory = $navigator_factory;
64 $this->services = $services;
65 $this->form_content = $form_content;
66 $this->table_content = $table_content;
67 $this->panel_content = $panel_content;
68 $this->root_content = $root_content;
69 }
70
72 {
73 return $this->services->manipulatorAdapter();
74 }
75
79 public function getContent(
80 SetInterface $set,
81 PathInterface $base_path,
82 ?RequestForFormInterface $request = null
83 ): \Generator {
84 $elements = $this->getElements($set, $base_path);
85 switch ($this->decideContentType(...$elements)) {
86 case self::FORM:
87 yield from $this->form_content->content(
88 $base_path,
89 $elements[0],
90 $request
91 );
92 return;
93
94 case self::TABLE:
95 yield from $this->table_content->content(
96 $base_path,
97 $request,
98 ...$elements
99 );
100 return;
101
102 case self::PANEL:
103 yield from $this->panel_content->content(
104 $base_path,
105 $elements[0],
106 false,
107 $request,
108 );
109 return;
110
111 case self::ROOT:
112 yield from $this->root_content->content(
113 $base_path,
114 $elements[0],
115 $request
116 );
117 return;
118
119 default:
120 throw new \ilMDEditorException(
121 'Invalid content type.'
122 );
123 }
124 }
125
126 protected function decideContentType(
127 ElementInterface ...$elements
128 ): string {
129 if ($elements[0]->isRoot()) {
130 return self::ROOT;
131 }
132 $tag = $this->editor_dictionary->tagForElement($elements[0]);
133 if (!$tag?->isLastInTree()) {
134 return self::PANEL;
135 }
136 if ($tag?->isCollected()) {
137 return self::TABLE;
138 }
139 return self::FORM;
140 }
141
145 protected function getElements(SetInterface $set, PathInterface $path): array
146 {
147 $res = $this->navigator_factory->navigator(
148 $path,
149 $set->getRoot()
150 )->elementsAtFinalStep();
151 return iterator_to_array($res);
152 }
153}
decideContentType(ElementInterface ... $elements)
Definition: FullEditor.php:126
NavigatorFactoryInterface $navigator_factory
Definition: FullEditor.php:46
getElements(SetInterface $set, PathInterface $path)
Definition: FullEditor.php:145
EditorDictionaryInterface $editor_dictionary
Definition: FullEditor.php:45
getContent(SetInterface $set, PathInterface $base_path, ?RequestForFormInterface $request=null)
Definition: FullEditor.php:79
__construct(EditorDictionaryInterface $editor_dictionary, NavigatorFactoryInterface $navigator_factory, FullEditorServices $services, FormContent $form_content, TableContent $table_content, PanelContent $panel_content, RootContent $root_content)
Definition: FullEditor.php:53
getRoot()
Returns the root element of the metadata set.
This describes commonalities between standard and primary buttons.
Definition: Button.php:34
This describes a Standard Dropdown.
Definition: Standard.php:27
This describes a standard form.
Definition: Standard.php:29
This describes how a panel could be modified during construction of UI.
Definition: Panel.php:31
$path
Definition: ltiservices.php:30
$res
Definition: ltiservices.php:69
if(!file_exists('../ilias.ini.php'))