Elgg  Version 4.x
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Elgg\SystemMessagesService Class Reference

System messages service. More...

Public Member Functions

 __construct (\ElggSession $session)
 Constructor. More...
 
 dumpRegister ($register_name= '')
 Empty and return the given register or all registers. More...
 
 count ($register_name="")
 Counts the number of messages, either globally or in a particular register. More...
 
 addSuccessMessage ($message)
 Display a system message on next page load. More...
 
 addErrorMessage ($message)
 Display an error on next page load. More...
 
 addMessage ($message)
 Adds a message to the registry. More...
 
 loadRegisters ()
 Load the registers from the session. More...
 
 saveRegisters (RegisterSet $set)
 Save the registers to the session. More...
 

Public Attributes

const SUCCESS = 'success'
 
const ERROR = 'error'
 
const SESSION_KEY = '_elgg_msgs'
 

Protected Attributes

 $session
 

Detailed Description

System messages service.

Use elgg()->system_messages

Since
1.11.0

Definition at line 15 of file SystemMessagesService.php.

Constructor & Destructor Documentation

Elgg\SystemMessagesService::__construct ( \ElggSession  $session)

Constructor.

Parameters
\ElggSession$sessionThe Elgg session

Definition at line 31 of file SystemMessagesService.php.

Member Function Documentation

Elgg\SystemMessagesService::addErrorMessage (   $message)

Display an error on next page load.

Parameters
string|string[]$message Error or errors to add
Returns
void

Definition at line 111 of file SystemMessagesService.php.

Elgg\SystemMessagesService::addMessage (   $message)

Adds a message to the registry.

Parameters
\ElggSystemMessage | array$messageError or errors to add
See also
::factory()
Returns
void
Exceptions
InvalidArgumentException
Since
4.2.0

Definition at line 134 of file SystemMessagesService.php.

Elgg\SystemMessagesService::addSuccessMessage (   $message)

Display a system message on next page load.

Parameters
string|string[]$message Message or messages to add
Returns
void

Definition at line 94 of file SystemMessagesService.php.

Elgg\SystemMessagesService::count (   $register_name = "")

Counts the number of messages, either globally or in a particular register.

Parameters
string$register_nameOptionally, the register
Returns
integer The number of messages

Definition at line 74 of file SystemMessagesService.php.

Elgg\SystemMessagesService::dumpRegister (   $register_name = '')

Empty and return the given register or all registers.

In each case, the return value is a filtered version of the full registers array.

Parameters
string$register_nameThe register. Empty string for all.
Returns
array The array of registers dumped

Definition at line 44 of file SystemMessagesService.php.

Elgg\SystemMessagesService::loadRegisters ( )

Load the registers from the session.

Returns
RegisterSet

Definition at line 153 of file SystemMessagesService.php.

Elgg\SystemMessagesService::saveRegisters ( RegisterSet  $set)

Save the registers to the session.

The method of displaying these messages differs depending upon plugins and viewtypes. The core default viewtype retrieves messages in views/default/page/shells/default.php and displays messages as javascript popups.

Messages are stored as strings in the Elgg session as ['msg'][$register] array.

Parameters
RegisterSet$setThe set of registers
Returns
void

Definition at line 175 of file SystemMessagesService.php.

Member Data Documentation

Elgg\SystemMessagesService::$session
protected

Definition at line 24 of file SystemMessagesService.php.

const Elgg\SystemMessagesService::ERROR = 'error'

Definition at line 18 of file SystemMessagesService.php.

const Elgg\SystemMessagesService::SESSION_KEY = '_elgg_msgs'

Definition at line 19 of file SystemMessagesService.php.

const Elgg\SystemMessagesService::SUCCESS = 'success'

Definition at line 17 of file SystemMessagesService.php.


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