ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilSystemStyleMessageStack Class Reference

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

+ Collaboration diagram for ilSystemStyleMessageStack:

Public Member Functions

 __construct (ilGlobalTemplateInterface $main_tpl)
 
 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...
 
 getUIComponentsMessages (\ILIAS\UI\Factory $f)
 Return Messages as UI Component. More...
 
 getJoinedMessages ()
 Return an array containing a string with all messages for each type. More...
 
 getMessages ()
 
 setMessages (array $messages)
 
 hasMessages ()
 Return wheter there are any message at all stored in the stack. More...
 
 sendMessages (bool $keep=true)
 Send messages via ilUtil to be displayed, still needed for messagees, that need to survive a redirect. More...
 

Protected Attributes

array $messages = []
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

Detailed Description

Used to stack messages to be shown to the user.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilSystemStyleMessageStack::__construct ( ilGlobalTemplateInterface  $main_tpl)

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

References $main_tpl.

34  {
35  $this->main_tpl = $main_tpl;
36  }

Member Function Documentation

◆ addMessage()

◆ getJoinedMessages()

ilSystemStyleMessageStack::getJoinedMessages ( )

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

Returns
string[]

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

References $message, and getMessages().

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

82  : array
83  {
84  $joined_messages = [];
85  foreach ($this->getMessages() as $message) {
86  if (!array_key_exists($message->getTypeId(), $joined_messages)) {
87  $joined_messages[$message->getTypeId()] = '';
88  }
89  $joined_messages[$message->getTypeId()] .= $message->getMessageOutput();
90  }
91  return $joined_messages;
92  }
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMessages()

ilSystemStyleMessageStack::getMessages ( )

◆ getUIComponentsMessages()

ilSystemStyleMessageStack::getUIComponentsMessages ( \ILIAS\UI\Factory  $f)

Return Messages as UI Component.

Returns
MessageBox[]

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

References $messages, getJoinedMessages(), ilSystemStyleMessage\TYPE_ERROR, ilSystemStyleMessage\TYPE_INFO, and ilSystemStyleMessage\TYPE_SUCCESS.

Referenced by ilSystemStyleMessageStackTest\testGetUIComponentsMessages().

58  : array
59  {
60  $messages = [];
61  foreach ($this->getJoinedMessages() as $type => $joined_message) {
62  switch ($type) {
64  $messages[] = $f->messageBox()->success($joined_message);
65  break;
67  $messages[] = $f->messageBox()->info($joined_message);
68  break;
70  $messages[] = $f->messageBox()->failure($joined_message);
71  break;
72  }
73  }
74  return $messages;
75  }
getJoinedMessages()
Return an array containing a string with all messages for each type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasMessages()

ilSystemStyleMessageStack::hasMessages ( )

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

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

References getMessages().

Referenced by ilSystemStyleMessageStackTest\testHasMessages().

113  : bool
114  {
115  return count($this->getMessages()) > 0;
116  }
+ 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.

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

Referenced by ilSystemStyleMessageStackTest\testPrependMessage().

41  : void
42  {
43  array_unshift($this->messages, $message);
44  }
+ Here is the caller graph for this function:

◆ sendMessages()

ilSystemStyleMessageStack::sendMessages ( bool  $keep = true)

Send messages via ilUtil to be displayed, still needed for messagees, that need to survive a redirect.

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

References getJoinedMessages(), ilSystemStyleMessage\TYPE_ERROR, ilSystemStyleMessage\TYPE_INFO, and ilSystemStyleMessage\TYPE_SUCCESS.

121  : void
122  {
123  foreach ($this->getJoinedMessages() as $type => $joined_message) {
124  switch ($type) {
126  $this->main_tpl->setOnScreenMessage('success', $joined_message, $keep);
127  break;
129  $this->main_tpl->setOnScreenMessage('info', $joined_message, $keep);
130  break;
132  $this->main_tpl->setOnScreenMessage('failure', $joined_message, $keep);
133  break;
134  }
135  }
136  }
getJoinedMessages()
Return an array containing a string with all messages for each type.
+ Here is the call graph for this function:

◆ setMessages()

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

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

References $messages.

105  : void
106  {
107  $this->messages = $messages;
108  }

Field Documentation

◆ $main_tpl

ilGlobalTemplateInterface ilSystemStyleMessageStack::$main_tpl
private

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

Referenced by __construct().

◆ $messages

array ilSystemStyleMessageStack::$messages = []
protected

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