ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

References $message, and getMessages().

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

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  }
catch(Exception $e) $message
+ 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.

References getMessages().

Referenced by ilSystemStyleMessageStackTest\testHasMessages().

98  {
99  return count($this->getMessages()) > 0;
100  }
+ 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.

Referenced by ilSystemStyleMessageStackTest\testPrependMessage().

23  {
24  array_unshift($this->messages, $message);
25  }
+ 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.

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

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  }
$type
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 87 of file class.ilSystemStyleMessageStack.php.

References $messages.

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

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: