ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
FormFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\UI\Factory as UIFactory;
33
35{
36 protected UIFactory $ui_factory;
39 protected EditorDictionary $editor_dictionary;
41
42 public function __construct(
43 UIFactory $ui_factory,
46 EditorDictionary $editor_dictionary,
48 ) {
49 $this->ui_factory = $ui_factory;
50 $this->link_provider = $link_provider;
51 $this->input_factory = $input_factory;
52 $this->editor_dictionary = $editor_dictionary;
53 $this->navigator_factory = $navigator_factory;
54 }
55
56 public function getUpdateForm(
57 PathInterface $base_path,
58 ElementInterface $element,
59 bool $with_title = true
60 ): StandardForm {
61 $link = $this->link_provider->update($base_path, $element);
62
63 return $this->getFormForElement(
64 $base_path,
65 $element,
66 $element,
67 $link,
68 $with_title,
69 false
70 );
71 }
72
73 public function getCreateForm(
74 PathInterface $base_path,
75 ElementInterface $element,
76 bool $with_title = true
77 ): StandardForm {
78 $link = $this->link_provider->create($base_path, $element);
79 $editor_tag = $this->editor_dictionary->tagForElement($element);
80 $context_element = $element;
81 if ($created_with = $editor_tag?->createdWith()) {
82 $element = $this->navigator_factory->navigator(
83 $created_with,
84 $element
85 )->lastElementAtFinalStep();
86 }
87 return $this->getFormForElement(
88 $base_path,
89 $element,
90 $context_element,
91 $link,
92 $with_title,
93 !$created_with && !$editor_tag?->isLastInTree()
94 );
95 }
96
97 protected function getFormForElement(
98 PathInterface $base_path,
99 ElementInterface $element,
100 ElementInterface $context_element,
101 URI $link,
102 bool $with_title,
103 bool $empty
104 ): StandardForm {
105 $section = [];
106 if (!$empty) {
107 $section = [$this->input_factory->getInputFields(
108 $element,
109 $context_element,
110 $with_title
111 )
112 ];
113 }
114 return $this->ui_factory->input()->container()->form()->standard(
115 (string) $link,
116 $section
117 );
118 }
119}
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
NavigatorFactoryInterface $navigator_factory
Definition: FormFactory.php:40
getUpdateForm(PathInterface $base_path, ElementInterface $element, bool $with_title=true)
Definition: FormFactory.php:56
__construct(UIFactory $ui_factory, LinkProvider $link_provider, InputFactory $input_factory, EditorDictionary $editor_dictionary, NavigatorFactoryInterface $navigator_factory)
Definition: FormFactory.php:42
getFormForElement(PathInterface $base_path, ElementInterface $element, ElementInterface $context_element, URI $link, bool $with_title, bool $empty)
Definition: FormFactory.php:97
getCreateForm(PathInterface $base_path, ElementInterface $element, bool $with_title=true)
Definition: FormFactory.php:73
This describes a standard form.
Definition: Standard.php:29