Elgg  Version master
Public Member Functions | Public Attributes | List of all members
Elgg\SystemMessagesService Class Reference

System messages service. More...

Public Member Functions

 __construct (protected\ElggSession $session)
 Constructor. More...
 
 dumpRegister (string $register_name= '')
 Empty and return the given register or all registers. More...
 
 count (string $register_name= '')
 Counts the number of messages, either globally or in a particular register. More...
 
 addSuccessMessage (string $message)
 Display a system message on next page load. More...
 
 addErrorMessage (string $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 (array $set)
 Save the registers to the session. More...
 

Public Attributes

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

Detailed Description

System messages service.

Use elgg()->system_messages

Since
1.11.0

Definition at line 14 of file SystemMessagesService.php.

Constructor & Destructor Documentation

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

Constructor.

Parameters
\ElggSession$sessionThe Elgg session

Definition at line 25 of file SystemMessagesService.php.

Member Function Documentation

Elgg\SystemMessagesService::addErrorMessage ( string  $message)

Display an error on next page load.

Parameters
string$messageError or errors to add
Returns
void

Definition at line 98 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 115 of file SystemMessagesService.php.

Elgg\SystemMessagesService::addSuccessMessage ( string  $message)

Display a system message on next page load.

Parameters
string$messageMessage or messages to add
Returns
void

Definition at line 87 of file SystemMessagesService.php.

Elgg\SystemMessagesService::count ( string  $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 67 of file SystemMessagesService.php.

Elgg\SystemMessagesService::dumpRegister ( string  $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 37 of file SystemMessagesService.php.

Elgg\SystemMessagesService::loadRegisters ( )

Load the registers from the session.

Returns
array

Definition at line 134 of file SystemMessagesService.php.

Elgg\SystemMessagesService::saveRegisters ( array  $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
array$setThe set of registers
Returns
void

Definition at line 151 of file SystemMessagesService.php.

Member Data Documentation

const Elgg\SystemMessagesService::ERROR = 'error'

Definition at line 17 of file SystemMessagesService.php.

const Elgg\SystemMessagesService::SESSION_KEY = '_elgg_msgs'

Definition at line 18 of file SystemMessagesService.php.

const Elgg\SystemMessagesService::SUCCESS = 'success'

Definition at line 16 of file SystemMessagesService.php.


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