ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
RoundTrip.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
36 
40 class 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,
68  $content,
69  array $inputs = [],
70  ?string $post_url = null
71  ) {
72  parent::__construct($signal_generator);
73 
74  $content = (null !== $content) ? $this->toArray($content) : [];
75  $this->checkArgListElements('content', $content, [Component::class]);
76 
77  $this->form = new Form(
78  $signal_generator,
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  {
117  return $this->action_buttons;
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 
150  public function getReplaceSignal(): ReplaceSignal
151  {
152  return $this->replace_signal;
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  {
247  return $this->submit_signal;
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 }
getCancelButtonLabel()
Get the custom label of the cancel button in the footer.
Definition: RoundTrip.php:135
getTitle()
Get the title of the modal.
Definition: RoundTrip.php:99
withDedicatedName(string $dedicated_name)
No dedicated name can be set for this subform.
Definition: RoundTrip.php:253
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:29
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initSignals()
Set the show/close/replace signals for this modal Set up the submit signal for form submissions...
Definition: RoundTrip.php:159
getActionButtons()
Get all action buttons in the footer of the modal.Button[]
Definition: RoundTrip.php:115
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
getReplaceSignal()
Get the signal to replace the content of this modal.
Definition: RoundTrip.php:150
withActionButtons(array $buttons)
Get a modal like this with the provided action buttons in the footer.Note that the footer always cont...
Definition: RoundTrip.php:123
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
withRequest(ServerRequestInterface $request)
Definition: RoundTrip.php:179
getContent()
Get the components representing the content of the modal.Component[]
Definition: RoundTrip.php:107
__construct(SignalGeneratorInterface $signal_generator, FieldFactory $field_factory, NameSource $name_source, string $title, $content, array $inputs=[], ?string $post_url=null)
Definition: RoundTrip.php:63
SignalGeneratorInterface $signal_generator
Definition: Modal.php:42
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21
withCancelButtonLabel(string $label)
Get the modal like this with the provided cancel button string.
Definition: RoundTrip.php:140
This signal replaces a component by ajax.
form( $class_path, string $cmd, string $submit_caption="")
__construct(Container $dic, ilPlugin $plugin)
A transformation is a function from one datatype to another.
Describes a source for input names.
Definition: NameSource.php:26