Class for flash messages
Module that shows flash messages. It handels messages for success, information and errors for the user., (*2)
By Christofer Jadelius, (*3)
This software is free software and carries a MIT license., (*4)
First you have to include this code in your composer.json file:, (*5)
"require": { "chja/cfmessage": "dev-master" },
After you have downloaded the package add this code to your front-controller:, (*6)
$di->set('Cfmessage', function() use ($di) { $message = new \Chja\Cfmessage\CfmessageAnax(); $message->setDI($di); return $message; });
Note: Before you start adding messages you will have to start a session if you have not done that yet., (*7)
Now you can start adding all the messages you want to use. below you can see some examples., (*8)
Info messages:, (*9)
$app->Cfmessage->addNotice('This is an information message');
Error messages:, (*10)
$app->Cfmessage->addError('This is an error message');
success messages:, (*11)
$app->Cfmessage->addSuccess('This is a success message');
warning messages:, (*12)
$app->Cfmessage->addWarning('This is a warning message');
When a message has been added it will be saved in the session, use these lines to print the message/messages:, (*13)
$messages = $app->Cfmessage->printMessage(); $app->views->addString($messages);
You can also clear the session by invoking this method:, (*14)
$app->Cfmessage->clearSession();
All the messages are using icons from Font Awesome. Font Awesome is not required but the meaning of the messages will be a little bit clearer if you use it., (*15)