Skip to content

Latest commit

 

History

History
118 lines (91 loc) · 3.44 KB

README.md

File metadata and controls

118 lines (91 loc) · 3.44 KB

Documentation

Table of content

  1. Drivers
  2. Channel
  3. Message object
  4. Exceptions
  5. Add messages
  6. Get messages
  7. Clear all messages

Drivers

Currently, SessionDriver is the only available driver. Feel free to implement your own driver (MUST implements DriverInterface) and send me a pull request!

Channel

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).

Message object

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);

Exceptions

All exceptions from that library extends FlashMessageException.

Add messages

The following method allows you to add a message

addFlashMessage ( string $message, string $type [, bool $unique = true, string $channel = 'general'] ) : void

Shortcut methods :

Success message

success ( string $message [, bool $unique = true, string $channel = 'general'] ) : void

Info message

info ( string $message [, bool $unique = true, string $channel = 'general'] ) : void

Warning message

warning ( string $message [, bool $unique = true, string $channel = 'general'] ) : void

Error message

error ( string $message [, bool $unique = true, string $channel = 'general'] ) : void

Get messages

Messages of a specific channel

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.

Get all messages

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.

Clear all messages

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.