PHP Class Contao\Message

The class handles system messages which are shown to the user. You can add messages from anywhere in the application. Usage: Message::addError('Please enter your name'); Message::addConfirm('The data has been stored'); Message::addInfo('You can upload only two files'); Message::addNew('There are two new messages');
Show file Open project: contao/core-bundle Class Usage Examples

Public Methods

Method Description
add ( string $strMessage, string $strType, string $strScope = TL_MODE ) Add a message
addConfirmation ( string $strMessage, string $strScope = TL_MODE ) Add a confirmation message
addError ( string $strMessage, string $strScope = TL_MODE ) Add an error message
addInfo ( string $strMessage, string $strScope = TL_MODE ) Add an info message
addNew ( string $strMessage, string $strScope = TL_MODE ) Add a new message
addRaw ( string $strMessage, string $strScope = TL_MODE ) Add a preformatted message
generate ( string $strScope = TL_MODE ) : string Return the messages with a wrapping container as HTML
generateUnwrapped ( string $strScope = TL_MODE ) : string Return the messages as HTML
getTypes ( ) : array Return all available message types
hasConfirmation ( string $strScope = TL_MODE ) : boolean Check if there are confirmation messages
hasError ( string $strScope = TL_MODE ) : boolean Check if there are error messages
hasInfo ( string $strScope = TL_MODE ) : boolean Check if there are info messages
hasMessages ( string $strScope = TL_MODE ) : boolean Check if there are any messages
hasNew ( string $strScope = TL_MODE ) : boolean Check if there are new messages
hasRaw ( string $strScope = TL_MODE ) : boolean Check if there are raw messages
reset ( ) Reset the message system

Protected Methods

Method Description
getFlashBagKey ( string $strType, string | null $strScope = TL_MODE ) : string Return the flash bag key

Method Details

add() public static method

Add a message
public static add ( string $strMessage, string $strType, string $strScope = TL_MODE )
$strMessage string The message text
$strType string The message type
$strScope string An optional message scope

addConfirmation() public static method

Add a confirmation message
public static addConfirmation ( string $strMessage, string $strScope = TL_MODE )
$strMessage string The confirmation message
$strScope string An optional message scope

addError() public static method

Add an error message
public static addError ( string $strMessage, string $strScope = TL_MODE )
$strMessage string The error message
$strScope string An optional message scope

addInfo() public static method

Add an info message
public static addInfo ( string $strMessage, string $strScope = TL_MODE )
$strMessage string The info message
$strScope string An optional message scope

addNew() public static method

Add a new message
public static addNew ( string $strMessage, string $strScope = TL_MODE )
$strMessage string The new message
$strScope string An optional message scope

addRaw() public static method

Add a preformatted message
public static addRaw ( string $strMessage, string $strScope = TL_MODE )
$strMessage string The preformatted message
$strScope string An optional message scope

generate() public static method

Return the messages with a wrapping container as HTML
public static generate ( string $strScope = TL_MODE ) : string
$strScope string An optional message scope
return string The messages HTML markup

generateUnwrapped() public static method

Return the messages as HTML
public static generateUnwrapped ( string $strScope = TL_MODE ) : string
$strScope string An optional message scope
return string The messages HTML markup

getFlashBagKey() protected static method

Return the flash bag key
protected static getFlashBagKey ( string $strType, string | null $strScope = TL_MODE ) : string
$strType string The message type
$strScope string | null The message scope
return string The flash bag key

getTypes() public static method

Return all available message types
public static getTypes ( ) : array
return array An array of message types

hasConfirmation() public static method

Check if there are confirmation messages
public static hasConfirmation ( string $strScope = TL_MODE ) : boolean
$strScope string An optional message scope
return boolean True if there are confirmation messages

hasError() public static method

Check if there are error messages
public static hasError ( string $strScope = TL_MODE ) : boolean
$strScope string An optional message scope
return boolean True if there are error messages

hasInfo() public static method

Check if there are info messages
public static hasInfo ( string $strScope = TL_MODE ) : boolean
$strScope string An optional message scope
return boolean True if there are info messages

hasMessages() public static method

Check if there are any messages
public static hasMessages ( string $strScope = TL_MODE ) : boolean
$strScope string An optional message scope
return boolean True if there are messages

hasNew() public static method

Check if there are new messages
public static hasNew ( string $strScope = TL_MODE ) : boolean
$strScope string An optional message scope
return boolean True if there are new messages

hasRaw() public static method

Check if there are raw messages
public static hasRaw ( string $strScope = TL_MODE ) : boolean
$strScope string An optional message scope
return boolean True if there are raw messages

reset() public static method

Reset the message system
public static reset ( )