ILIAS  release_8 Revision v8.24
RoundTrip.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
34use Psr\Http\Message\ServerRequestInterface;
35
39class RoundTrip extends Modal implements M\RoundTrip
40{
44 protected array $action_buttons = [];
45
49 protected array $content;
50
54 protected string $title;
55 protected string $cancel_button_label = 'cancel';
56 protected string $submit_button_label = 'save';
57
62 public function __construct(
64 FieldFactory $field_factory,
65 NameSource $name_source,
66 string $title,
68 array $inputs = [],
69 ?string $post_url = null
70 ) {
72
73 $content = (null !== $content) ? $this->toArray($content) : [];
74 $this->checkArgListElements('content', $content, [Component::class]);
75
76 $this->form = new FormWithoutSubmitButton(
78 $field_factory,
79 $name_source,
80 $post_url ?? '',
81 $inputs,
82 );
83
84 $this->title = $title;
85 $this->content = $content;
86
87 $this->initSignals();
88 }
89
91 {
92 return $this->form;
93 }
94
98 public function getTitle(): string
99 {
100 return $this->title;
101 }
102
106 public function getContent(): array
107 {
108 return $this->content;
109 }
110
114 public function getActionButtons(): array
115 {
117 }
118
122 public function withActionButtons(array $buttons): self
123 {
124 $types = [Button\Button::class];
125 $this->checkArgListElements('buttons', $buttons, $types);
126 $clone = clone $this;
127 $clone->action_buttons = $buttons;
128 return $clone;
129 }
130
134 public function getCancelButtonLabel(): string
135 {
137 }
138
139 public function withCancelButtonLabel(string $label): self
140 {
141 $clone = clone $this;
142 $clone->cancel_button_label = $label;
143 return $clone;
144 }
145
150 {
152 }
153
158 public function initSignals(): void
159 {
160 parent::initSignals();
161
163 $this->replace_signal = $this->signal_generator->create(ReplaceSignal::class);
164 $this->submit_signal = $this->signal_generator->create();
165 }
166
170 public function getInputs(): array
171 {
172 return $this->form->getInputs();
173 }
174
178 public function withRequest(ServerRequestInterface $request): self
179 {
180 $clone = clone $this;
181 $clone->form = $clone->form->withRequest($request);
182 return $clone;
183 }
184
188 public function withAdditionalTransformation(Transformation $trafo): self
189 {
190 $clone = clone $this;
191 $clone->form = $clone->form->withAdditionalTransformation($trafo);
192 return $clone;
193 }
194
198 public function getData()
199 {
200 return $this->form->getData();
201 }
202
206 public function getError(): ?string
207 {
208 return $this->form->getError();
209 }
210
214 public function getPostURL(): string
215 {
216 return $this->form->getPostURL();
217 }
218
222 public function withSubmitCaption(string $caption): self
223 {
224 $clone = clone $this;
225 $clone->submit_button_label = $caption;
226 return $clone;
227 }
228
232 public function getSubmitCaption(): ?string
233 {
235 }
236
237 public function getSubmitSignal(): Signal
238 {
240 }
241
245 public function withDedicatedName(string $dedicated_name): self
246 {
247 return $this;
248 }
249}
SignalGeneratorInterface $signal_generator
Definition: Modal.php:42
withDedicatedName(string $dedicated_name)
No dedicated name can be set for this subform.
Definition: RoundTrip.php:245
withRequest(ServerRequestInterface $request)
Definition: RoundTrip.php:178
__construct(SignalGeneratorInterface $signal_generator, FieldFactory $field_factory, NameSource $name_source, string $title, $content, array $inputs=[], ?string $post_url=null)
Definition: RoundTrip.php:62
initSignals()
Set the show/close/replace signals for this modal Set up the submit signal for form submissions.
Definition: RoundTrip.php:158
withSubmitCaption(string $caption)
@inheritDoc
Definition: RoundTrip.php:222
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:32
This is what a factory for input fields looks like.
Definition: Factory.php:29
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)
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21