ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
Modal.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
30 
36 abstract class Modal implements M\Modal
37 {
38  use ComponentHelper;
40  use Triggerer;
41 
43  protected Signal $show_signal;
44  protected Signal $close_signal;
45  protected string $async_render_url = '';
46  protected bool $close_with_keyboard = true;
47 
48  public function __construct(SignalGeneratorInterface $signal_generator)
49  {
50  $this->signal_generator = $signal_generator;
51  $this->initSignals();
52  }
53 
57  public function getAsyncRenderUrl(): string
58  {
60  }
61 
65  public function withAsyncRenderUrl(string $url): M\Modal
66  {
67  $clone = clone $this;
68  $clone->async_render_url = $url;
69  return $clone;
70  }
71 
75  public function withCloseWithKeyboard(bool $state): M\Modal
76  {
77  $clone = clone $this;
78  $clone->close_with_keyboard = $state;
79  return $clone;
80  }
81 
85  public function getCloseWithKeyboard(): bool
86  {
88  }
89 
93  public function getShowSignal(): Signal
94  {
95  return $this->show_signal;
96  }
97 
101  public function getCloseSignal(): Signal
102  {
103  return $this->close_signal;
104  }
105 
109  public function withResetSignals(): Modal
110  {
111  $clone = clone $this;
112  $clone->initSignals();
113  return $clone;
114  }
115 
119  public function withOnLoad(Signal $signal): Onloadable
120  {
121  return $this->withTriggeredSignal($signal, 'ready');
122  }
123 
127  public function appendOnLoad(Signal $signal): Onloadable
128  {
129  return $this->appendTriggeredSignal($signal, 'ready');
130  }
131 
132  public function withOnClose(Signal $signal): self
133  {
134  return $this->withTriggeredSignal($signal, 'hidden.bs.modal');
135  }
136 
137  public function appendOnClose(Signal $signal): self
138  {
139  return $this->withTriggeredSignal($signal, 'hidden.bs.modal');
140  }
141 
145  public function initSignals(): void
146  {
147  $this->show_signal = $this->signal_generator->create();
148  $this->close_signal = $this->signal_generator->create();
149  }
150 }
appendTriggeredSignal(C\Signal $signal, string $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:47
withTriggeredSignal(C\Signal $signal, string $event)
Add a triggered signal, replacing any other signals registered on the same event. ...
Definition: Triggerer.php:62
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
__construct(SignalGeneratorInterface $signal_generator)
Definition: Modal.php:48
SignalGeneratorInterface $signal_generator
Definition: Modal.php:42
initSignals()
Set the show and close signals for this modal.
Definition: Modal.php:145
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21
$url