ILIAS  release_8 Revision v8.23
MessageBox.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
23 use ILIAS\UI\Component as C;
25 
26 class MessageBox implements C\MessageBox\MessageBox
27 {
28  use ComponentHelper;
29 
33  private static array $types = [
34  self::FAILURE,
35  self::SUCCESS,
36  self::INFO,
37  self::CONFIRMATION
38  ];
39 
40  private string $type;
41  private string $message_text;
42  private array $buttons = [];
43  private array $links = [];
44 
45  public function __construct($type, string $message_text)
46  {
47  $this->checkArgIsElement("type", $type, self::$types, "message box type");
48  $this->type = $type;
49  $this->message_text = $message_text;
50  }
51 
55  public function getType(): string
56  {
57  return $this->type;
58  }
59 
63  public function getMessageText(): string
64  {
65  return $this->message_text;
66  }
67 
71  public function getButtons(): array
72  {
73  return $this->buttons;
74  }
75 
79  public function getLinks(): array
80  {
81  return $this->links;
82  }
83 
87  public function withButtons(array $buttons): C\MessageBox\MessageBox
88  {
89  $types = array(C\Component::class);
90  $this->checkArgListElements("buttons", $buttons, $types);
91 
92  $clone = clone $this;
93  $clone->buttons = $buttons;
94  return $clone;
95  }
96 
100  public function withLinks(array $links): C\MessageBox\MessageBox
101  {
102  $types = array(C\Component::class);
103  $this->checkArgListElements("links", $links, $types);
104 
105  $clone = clone $this;
106  $clone->links = $links;
107  return $clone;
108  }
109 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21