ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSystemStyleMessageStack.php
Go to the documentation of this file.
1<?php
2
10
14 protected $messages = array();
15
21 public function prependMessage(ilSystemStyleMessage $message){
22 array_unshift($this->messages , $message);
23 }
24
30 public function addMessage(ilSystemStyleMessage $message){
31 $this->messages[] = $message;
32 }
33
39 public function sendMessages($keep = false){
40 foreach($this->getJoinedMessages() as $type => $joined_message){
41 switch($type){
43 ilUtil::sendSuccess($joined_message,$keep);
44 break;
46 ilUtil::sendInfo($joined_message,$keep);
47 break;
49 ilUtil::sendFailure($joined_message,$keep);
50 break;
51 }
52 }
53 }
54
60 public function getJoinedMessages(){
61 $joined_messages = [];
62 foreach($this->getMessages() as $message){
63 if(!array_key_exists($message->getTypeId(),$joined_messages)){
64 $joined_messages[$message->getTypeId()] = "";
65 }
66 $joined_messages[$message->getTypeId()] .= $message->getMessageOutput();
67 }
68 return $joined_messages;
69 }
70
74 public function getMessages()
75 {
76 return $this->messages;
77 }
78
82 public function setMessages($messages)
83 {
84 $this->messages = $messages;
85 }
86
92 public function hasMessages(){
93 return count($this->getMessages()) > 0;
94 }
95
96}
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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.