ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSystemStyleMessageStack Class Reference

Used to stack messages to be shown to the user. More...

+ Collaboration diagram for ilSystemStyleMessageStack:

Public Member Functions

 prependMessage (ilSystemStyleMessage $message)
 Add a message to be displayed before all others. More...
 
 addMessage (ilSystemStyleMessage $message)
 Add a message to be displayed by the stack. More...
 
 sendMessages ($keep=false)
 Send messages via ilUtil to be displayed. More...
 
 getJoinedMessages ()
 Return an array containing a string with all messages for each type. More...
 
 getMessages ()
 
 setMessages ($messages)
 
 hasMessages ()
 Return wheter there are any message at all stored in the stack. More...
 

Protected Attributes

 $messages = array()
 

Detailed Description

Used to stack messages to be shown to the user.

Mostly used in ilUtil-Classes to present via ilUtil::sendMessage()

Author
Timon Amstutz timon.nosp@m..ams.nosp@m.tutz@.nosp@m.ilub.nosp@m..unib.nosp@m.e.ch
Version
$Id$*

Definition at line 9 of file class.ilSystemStyleMessageStack.php.

Member Function Documentation

◆ addMessage()

ilSystemStyleMessageStack::addMessage ( ilSystemStyleMessage  $message)

◆ getJoinedMessages()

ilSystemStyleMessageStack::getJoinedMessages ( )

Return an array containing a string with all messages for each type.

Returns
string[]

Definition at line 64 of file class.ilSystemStyleMessageStack.php.

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 }

References $message, and getMessages().

Referenced by sendMessages(), and ilSystemStyleMessageStackTest\testJoinedMessages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMessages()

◆ hasMessages()

ilSystemStyleMessageStack::hasMessages ( )

Return wheter there are any message at all stored in the stack.

Returns
bool

Definition at line 97 of file class.ilSystemStyleMessageStack.php.

98 {
99 return count($this->getMessages()) > 0;
100 }

References getMessages().

Referenced by ilSystemStyleMessageStackTest\testHasMessages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prependMessage()

ilSystemStyleMessageStack::prependMessage ( ilSystemStyleMessage  $message)

Add a message to be displayed before all others.

Parameters
ilSystemStyleMessage$message

Definition at line 22 of file class.ilSystemStyleMessageStack.php.

23 {
24 array_unshift($this->messages, $message);
25 }

References $message.

Referenced by ilSystemStyleMessageStackTest\testPrependMessage().

+ Here is the caller graph for this function:

◆ sendMessages()

ilSystemStyleMessageStack::sendMessages (   $keep = false)

Send messages via ilUtil to be displayed.

Parameters
bool | false$keep

Definition at line 42 of file class.ilSystemStyleMessageStack.php.

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 }
getJoinedMessages()
Return an array containing a string with all messages for each type.
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.
$type

References $type, getJoinedMessages(), ilUtil\sendFailure(), ilUtil\sendInfo(), ilUtil\sendSuccess(), ilSystemStyleMessage\TYPE_ERROR, ilSystemStyleMessage\TYPE_INFO, and ilSystemStyleMessage\TYPE_SUCCESS.

+ Here is the call graph for this function:

◆ setMessages()

ilSystemStyleMessageStack::setMessages (   $messages)
Parameters
ilSystemStyleMessage[]$messages

Definition at line 87 of file class.ilSystemStyleMessageStack.php.

88 {
89 $this->messages = $messages;
90 }

References $messages.

Field Documentation

◆ $messages

ilSystemStyleMessageStack::$messages = array()
protected

Definition at line 15 of file class.ilSystemStyleMessageStack.php.

Referenced by getMessages(), and setMessages().


The documentation for this class was generated from the following file: