Currently, SessionDriver is the only available driver. Feel free to implement your own driver (MUST implements DriverInterface) and send me a pull request!
The previous example didn't specified a channel so it was saved in "general" (default) channel. You can use multiples channels to split your messages.
<?php
$flashMessageController->success('Your profile was updated successfully !', true, 'account.messages');
The second parameter is for uniqueness (default : true). If the same message already exists on that channel, it will be ignored. The third parameter is the channel name (default : general).
All messages implements FlashMessageInterface and offers those methods
$message->getUuid() : string;
$message->setUuid(string $uuid);
$message->getMessage() : string;
$message->setMessage(string $message);
$message->getType() : string;
$message->setType(string $type);
All exceptions from that library extends FlashMessageException.
The following method allows you to add a message
addFlashMessage ( string $message, string $type [, bool $unique = true, string $channel = 'general'] ) : void
success ( string $message [, bool $unique = true, string $channel = 'general'] ) : void
info ( string $message [, bool $unique = true, string $channel = 'general'] ) : void
warning ( string $message [, bool $unique = true, string $channel = 'general'] ) : void
error ( string $message [, bool $unique = true, string $channel = 'general'] ) : void
getMessages ( [string $channel = 'general', bool $clear = true] ) : FlashMessageInterface[]
This return an array of objects implementing FlashMessageInterface. By default, the messages are deleted when opened. To prevent this, you can set $clear to false.
getAllMessages ( [bool $clear = true] ) : array
This return an bi-dimensionnal array holdings each messages of each channels. By default, the messages are deleted when opened. To prevent this, you can set $clear to false.
clearAllMessages ( [string $channel = 'general'] ) : void
This will clear all messages. Optionnaly, you can specify a channel to clear only that channel. Otherwise, all channels will be cleared.