ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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()

◆ getJoinedMessages()

ilSystemStyleMessageStack::getJoinedMessages ( )

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

Returns
string[]

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

References getMessages().

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

60  {
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  }
+ 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 92 of file class.ilSystemStyleMessageStack.php.

References getMessages().

Referenced by ilSystemStyleMessageStackTest\testHasMessages().

92  {
93  return count($this->getMessages()) > 0;
94  }
+ 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 21 of file class.ilSystemStyleMessageStack.php.

Referenced by ilSystemStyleMessageStackTest\testPrependMessage().

21  {
22  array_unshift($this->messages , $message);
23  }
+ 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 39 of file class.ilSystemStyleMessageStack.php.

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

39  {
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  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
getJoinedMessages()
Return an array containing a string with all messages for each type.
+ Here is the call graph for this function:

◆ setMessages()

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

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

References $messages.

83  {
84  $this->messages = $messages;
85  }

Field Documentation

◆ $messages

ilSystemStyleMessageStack::$messages = array()
protected

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

Referenced by getMessages(), and setMessages().


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