ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
RoundTrip.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
35use Psr\Http\Message\ServerRequestInterface;
36
40class RoundTrip extends Modal implements M\RoundTrip
41{
45 protected array $action_buttons = [];
46
50 protected array $content;
51
54 protected Form $form;
55 protected string $title;
56 protected ?string $cancel_button_label = null;
57 protected ?string $submit_button_label = null;
58
63 public function __construct(
65 FieldFactory $field_factory,
66 NameSource $name_source,
67 string $title,
69 array $inputs = [],
70 ?string $post_url = null
71 ) {
73
74 $content = (null !== $content) ? $this->toArray($content) : [];
75 $this->checkArgListElements('content', $content, [Component::class]);
76
77 $this->form = new Form(
79 $field_factory,
80 $name_source,
81 $post_url ?? '',
82 $inputs,
83 );
84
85 $this->title = $title;
86 $this->content = $content;
87
88 $this->initSignals();
89 }
90
91 public function getForm(): Form
92 {
93 return $this->form;
94 }
95
99 public function getTitle(): string
100 {
101 return $this->title;
102 }
103
107 public function getContent(): array
108 {
109 return $this->content;
110 }
111
115 public function getActionButtons(): array
116 {
118 }
119
123 public function withActionButtons(array $buttons): self
124 {
125 $types = [Button\Button::class];
126 $this->checkArgListElements('buttons', $buttons, $types);
127 $clone = clone $this;
128 $clone->action_buttons = $buttons;
129 return $clone;
130 }
131
135 public function getCancelButtonLabel(): ?string
136 {
138 }
139
140 public function withCancelButtonLabel(string $label): self
141 {
142 $clone = clone $this;
143 $clone->cancel_button_label = $label;
144 return $clone;
145 }
146
151 {
153 }
154
159 public function initSignals(): void
160 {
161 parent::initSignals();
162
164 $this->replace_signal = $this->signal_generator->create(ReplaceSignal::class);
165 $this->submit_signal = $this->signal_generator->create();
166 }
167
171 public function getInputs(): array
172 {
173 return $this->form->getInputs();
174 }
175
179 public function withRequest(ServerRequestInterface $request): self
180 {
181 $clone = clone $this;
182 $clone->form = $clone->form->withRequest($request);
183 return $clone;
184 }
185
186 public function withInput(InputData $input_data): self
187 {
188 $clone = clone $this;
189 $clone->form = $clone->form->withInput($request);
190 return $clone;
191 }
192
196 public function withAdditionalTransformation(Transformation $trafo): self
197 {
198 $clone = clone $this;
199 $clone->form = $clone->form->withAdditionalTransformation($trafo);
200 return $clone;
201 }
202
206 public function getData()
207 {
208 return $this->form->getData();
209 }
210
214 public function getError(): ?string
215 {
216 return $this->form->getError();
217 }
218
222 public function getPostURL(): string
223 {
224 return $this->form->getPostURL();
225 }
226
230 public function withSubmitLabel(string $caption): self
231 {
232 $clone = clone $this;
233 $clone->submit_button_label = $caption;
234 return $clone;
235 }
236
240 public function getSubmitLabel(): ?string
241 {
243 }
244
245 public function getSubmitSignal(): Signal
246 {
248 }
249
253 public function withDedicatedName(string $dedicated_name): self
254 {
255 return $this;
256 }
257
261 public function getPromptButtons(): array
262 {
263 return $this->buttons;
264 }
265
269 public function getPromptTitle(): string
270 {
271 return $this->type;
272 }
273}
Factory for Date Formats.
Definition: Factory.php:27
SignalGeneratorInterface $signal_generator
Definition: Modal.php:42
withDedicatedName(string $dedicated_name)
No dedicated name can be set for this subform.
Definition: RoundTrip.php:253
withRequest(ServerRequestInterface $request)
Definition: RoundTrip.php:179
withSubmitLabel(string $caption)
@inheritDoc
Definition: RoundTrip.php:230
__construct(SignalGeneratorInterface $signal_generator, FieldFactory $field_factory, NameSource $name_source, string $title, $content, array $inputs=[], ?string $post_url=null)
Definition: RoundTrip.php:63
initSignals()
Set the show/close/replace signals for this modal Set up the submit signal for form submissions.
Definition: RoundTrip.php:159
A transformation is a function from one datatype to another.
A component is the most general form of an entity in the UI.
Definition: Component.php:28
This describes inputs that can be used in forms.
Definition: FormInput.php:33
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:30
This signal replaces a component by ajax.
Describes a source for input names.
Definition: NameSource.php:27
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd, string $submit_caption="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21