ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilSystemStyleMessageStack.php
Go to the documentation of this file.
1<?php
2
10{
11
15 protected $messages = array();
16
23 {
24 array_unshift($this->messages, $message);
25 }
26
33 {
34 $this->messages[] = $message;
35 }
36
42 public function sendMessages($keep = false)
43 {
44 foreach ($this->getJoinedMessages() as $type => $joined_message) {
45 switch ($type) {
47 ilUtil::sendSuccess($joined_message, $keep);
48 break;
50 ilUtil::sendInfo($joined_message, $keep);
51 break;
53 ilUtil::sendFailure($joined_message, $keep);
54 break;
55 }
56 }
57 }
58
64 public function getJoinedMessages()
65 {
66 $joined_messages = [];
67 foreach ($this->getMessages() as $message) {
68 if (!array_key_exists($message->getTypeId(), $joined_messages)) {
69 $joined_messages[$message->getTypeId()] = "";
70 }
71 $joined_messages[$message->getTypeId()] .= $message->getMessageOutput();
72 }
73 return $joined_messages;
74 }
75
79 public function getMessages()
80 {
81 return $this->messages;
82 }
83
87 public function setMessages($messages)
88 {
89 $this->messages = $messages;
90 }
91
97 public function hasMessages()
98 {
99 return count($this->getMessages()) > 0;
100 }
101}
An exception for terminatinating execution or to throw for unit testing.
Used to stack messages to be shown to the user.
hasMessages()
Return wheter there are any message at all stored in the stack.
sendMessages($keep=false)
Send messages via ilUtil to be displayed.
prependMessage(ilSystemStyleMessage $message)
Add a message to be displayed before all others.
getJoinedMessages()
Return an array containing a string with all messages for each type.
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$type
$message
Definition: xapiexit.php:14