ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
FullEditor.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Generator;
26use ILIAS\UI\Component\Dropdown\Standard as StandardDropdown;
28use ILIAS\MetaData\Editor\Dictionary\DictionaryInterface as EditorDictionaryInterface;
36
38{
39 public const string TABLE = 'table';
40 public const string PANEL = 'panel';
41 public const string ROOT = 'root';
42 public const string FORM = 'form';
43
44 public function __construct(
45 protected EditorDictionaryInterface $editor_dictionary,
46 protected NavigatorFactoryInterface $navigator_factory,
47 protected FormContent $form_content,
48 protected TableContent $table_content,
49 protected PanelContent $panel_content,
50 protected RootContent $root_content
51 ) {
52 }
53
57 public function getContent(
58 SetInterface $set,
59 PathInterface $base_path,
60 ?RequestForFormInterface $request = null
61 ): Generator {
62 $elements = $this->getElements($set, $base_path);
63 switch ($this->decideContentType(...$elements)) {
64 case self::FORM:
65 yield from $this->form_content->content(
66 $base_path,
67 $elements[0],
68 $request
69 );
70 return;
71
72 case self::TABLE:
73 yield from $this->table_content->content(
74 $base_path,
75 $request,
76 ...$elements
77 );
78 return;
79
80 case self::PANEL:
81 yield from $this->panel_content->content(
82 $base_path,
83 $elements[0],
84 false,
85 $request,
86 );
87 return;
88
89 case self::ROOT:
90 yield from $this->root_content->content(
91 $base_path,
92 $elements[0],
93 $request
94 );
95 return;
96
97 default:
98 throw new \ilMDEditorException(
99 'Invalid content type.'
100 );
101 }
102 }
103
104 protected function decideContentType(
105 ElementInterface ...$elements
106 ): string {
107 if ($elements[0]->isRoot()) {
108 return self::ROOT;
109 }
110 $tag = $this->editor_dictionary->tagForElement($elements[0]);
111 if (!$tag?->isLastInTree()) {
112 return self::PANEL;
113 }
114 if ($tag?->isCollected()) {
115 return self::TABLE;
116 }
117 return self::FORM;
118 }
119
123 protected function getElements(SetInterface $set, PathInterface $path): array
124 {
125 $res = $this->navigator_factory->navigator(
126 $path,
127 $set->getRoot()
128 )->elementsAtFinalStep();
129 return iterator_to_array($res);
130 }
131}
decideContentType(ElementInterface ... $elements)
Definition: FullEditor.php:104
__construct(protected EditorDictionaryInterface $editor_dictionary, protected NavigatorFactoryInterface $navigator_factory, protected FormContent $form_content, protected TableContent $table_content, protected PanelContent $panel_content, protected RootContent $root_content)
Definition: FullEditor.php:44
getElements(SetInterface $set, PathInterface $path)
Definition: FullEditor.php:123
getContent(SetInterface $set, PathInterface $base_path, ?RequestForFormInterface $request=null)
Definition: FullEditor.php:57
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:30
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'))