ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
FormFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\UI\Factory as UIFactory;
32
34{
35 protected UIFactory $ui_factory;
38 protected EditorDictionary $editor_dictionary;
40
41 public function __construct(
42 UIFactory $ui_factory,
45 EditorDictionary $editor_dictionary,
47 ) {
48 $this->ui_factory = $ui_factory;
49 $this->link_provider = $link_provider;
50 $this->input_factory = $input_factory;
51 $this->editor_dictionary = $editor_dictionary;
52 $this->navigator_factory = $navigator_factory;
53 }
54
55 public function getUpdateForm(
56 PathInterface $base_path,
57 ElementInterface $element,
58 bool $with_title = true
59 ): StandardForm {
60 $link = $this->link_provider->update($base_path, $element);
61
62 return $this->getFormForElement(
63 $base_path,
64 $element,
65 $element,
66 $link,
67 $with_title,
68 false
69 );
70 }
71
72 public function getCreateForm(
73 PathInterface $base_path,
74 ElementInterface $element,
75 bool $with_title = true
76 ): StandardForm {
77 $link = $this->link_provider->create($base_path, $element);
78 $editor_tag = $this->editor_dictionary->tagForElement($element);
79 $context_element = $element;
80 if ($created_with = $editor_tag?->createdWith()) {
81 $element = $this->navigator_factory->navigator(
82 $created_with,
83 $element
84 )->lastElementAtFinalStep();
85 }
86 return $this->getFormForElement(
87 $base_path,
88 $element,
89 $context_element,
90 $link,
91 $with_title,
92 !$created_with && !$editor_tag?->isLastInTree()
93 );
94 }
95
96 protected function getFormForElement(
97 PathInterface $base_path,
98 ElementInterface $element,
99 ElementInterface $context_element,
100 URI $link,
101 bool $with_title,
102 bool $empty
103 ): StandardForm {
104 $section = [];
105 if (!$empty) {
106 $section = [$this->input_factory->getInputFields(
107 $element,
108 $context_element,
109 $with_title
110 )
111 ];
112 }
113 return $this->ui_factory->input()->container()->form()->standard(
114 (string) $link,
115 $section
116 );
117 }
118}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
getCreateForm(PathInterface $base_path, ElementInterface $element, bool $with_title=true)
Definition: FormFactory.php:72
getUpdateForm(PathInterface $base_path, ElementInterface $element, bool $with_title=true)
Definition: FormFactory.php:55
getFormForElement(PathInterface $base_path, ElementInterface $element, ElementInterface $context_element, URI $link, bool $with_title, bool $empty)
Definition: FormFactory.php:96
__construct(UIFactory $ui_factory, LinkProvider $link_provider, InputFactory $input_factory, EditorDictionary $editor_dictionary, NavigatorFactoryInterface $navigator_factory)
Definition: FormFactory.php:41
This describes a standard form.
Definition: Standard.php:30