Contao\Message::add PHP Method

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
    public static function add($strMessage, $strType, $strScope = TL_MODE)
    {
        if ($strMessage == '') {
            return;
        }
        if (!in_array($strType, static::getTypes())) {
            throw new \Exception("Invalid message type {$strType}");
        }
        \System::getContainer()->get('session')->getFlashBag()->add(static::getFlashBagKey($strType, $strScope), $strMessage);
    }

Usage Example

Example #1
0
 /**
  * Add a message
  *
  * @param string $strMessage The message
  * @param string $strType    The message type
  *
  * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
  *             Use Message::add() instead.
  */
 protected function addMessage($strMessage, $strType)
 {
     @trigger_error('Using System::addMessage() has been deprecated and will no longer work in Contao 5.0. Use Message::add() instead.', E_USER_DEPRECATED);
     \Message::add($strMessage, $strType);
 }
All Usage Examples Of Contao\Message::add