ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Toast.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
31 
32 class Toast implements ComponentInterface\Toast
33 {
34  use ComponentHelper;
36 
40  protected $title;
41  protected Icon $icon;
42  protected string $description = '';
44  protected array $links = [];
45  protected string $action = '';
47  protected Signal $signal;
48 
49  public function __construct($title, Icon $icon, SignalGeneratorInterface $signal_generator)
50  {
51  $this->signal_generator = $signal_generator;
52  $this->title = $title;
53  $this->icon = $icon;
54  }
55 
59  public function getTitle()
60  {
61  return $this->title;
62  }
63 
64  public function withDescription(string $description): ComponentInterface\Toast
65  {
66  $new = clone $this;
67  $new->description = $description;
68  return $new;
69  }
70 
71  public function getDescription(): string
72  {
73  return $this->description;
74  }
75 
77  {
78  $new = clone $this;
79  $new->links[] = $link;
80  return $new;
81  }
82 
84  {
85  $new = clone $this;
86  $new->links = [];
87  return $new;
88  }
89 
93  public function getLinks(): array
94  {
95  return $this->links;
96  }
97 
98  public function withAction(string $action): ComponentInterface\Toast
99  {
100  $new = clone $this;
101  $new->action = $action;
102  return $new;
103  }
104 
105  public function getAction(): string
106  {
107  return $this->action;
108  }
109 
110  public function getIcon(): Icon
111  {
112  return $this->icon;
113  }
114 
115  public function initSignals(): void
116  {
117  $this->signal = $this->signal_generator->create();
118  }
119 
120  public function getShowSignal(): Signal
121  {
122  return $this->signal;
123  }
124 }
__construct($title, Icon $icon, SignalGeneratorInterface $signal_generator)
Definition: Toast.php:49
getShowSignal()
Get the signal to show this toast in the frontend.
Definition: Toast.php:120
withAction(string $action)
Create a copy of this toast with an url, which is called asynchronous when the user interact with the...
Definition: Toast.php:98
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
SignalGeneratorInterface $signal_generator
Definition: Toast.php:46
initSignals()
Init the default signals.
Definition: Toast.php:115