ILIAS  release_7 Revision v7.30-3-g800a261c036
MessageBox.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2018 Thomas Famula <famula@leifos.de> Extended GPL, see docs/LICENSE */
4
6
9
11{
13
17 private $type;
18
23
27 private $buttons = [];
28
32 private $links = [];
33
37 private static $types = array(self::FAILURE
38 , self::SUCCESS
39 , self::INFO
40 , self::CONFIRMATION
41 );
42
47 {
48 $this->checkArgIsElement("type", $type, self::$types, "message box type");
49 $this->checkStringArg("message_text", $message_text);
50 $this->type = $type;
51 $this->message_text = $message_text;
52 }
53
57 public function getType()
58 {
59 return $this->type;
60 }
61
65 public function getMessageText()
66 {
68 }
69
73 public function getButtons() : array
74 {
75 return $this->buttons;
76 }
77
81 public function getLinks() : array
82 {
83 return $this->links;
84 }
85
89 public function withButtons(array $buttons)
90 {
91 $types = array(C\Component::class);
92 $this->checkArgListElements("buttons", $buttons, $types);
93
94 $clone = clone $this;
95 $clone->buttons = $buttons;
96 return $clone;
97 }
98
102 public function withLinks(array $links)
103 {
104 $types = array(C\Component::class);
105 $this->checkArgListElements("links", $links, $types);
106
107 $clone = clone $this;
108 $clone->links = $links;
109 return $clone;
110 }
111}
An exception for terminatinating execution or to throw for unit testing.
checkStringArg($which, $value)
Throw an InvalidArgumentException if $value is no string.
checkArgListElements($which, array &$values, $classes)
Check every element of the list if it is an instance of one of the given classes.
trait ComponentHelper
Provides common functionality for component implementations.
checkArgIsElement($which, $value, $array, $name)
Throw an InvalidArgumentException if $value is not an element of array.