Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Kohana v3.0+ flash messaging system

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 classes
Octocat-spinner-32 config
Octocat-spinner-32 guide
Octocat-spinner-32 views
Octocat-spinner-32 .gitignore
Octocat-spinner-32 readme.md
readme.md

Message

A flash messaging system for Kohana v3.0 and higher.

To use, download the source, extract and rename to message. Move that folder into your modules directory and activate in your bootstrap.

Usage

To set a flash message all it takes is the following

Message::set( type, message );

Wrapper methods

There are also methods that are wrappers for the different types of messages Message::error(message) Message::success(message) Message::notice(message) Message::warn(message)

type: Use a constant that can be found below
message: A message string or array of message strings

When you need to get a message you can: echo Message::display(); or echo Message::render();

Messages

There are 4 constants you can use to set a message

Message::ERROR = 'error'
Message::NOTICE = 'notice'
Message::SUCCESS = 'success'
Message::WARN = 'warn'

Style

The message class produces the following code by default

  • Message
  • ... Repeated if an array

To style, set #message and the classes for the constants .error, .success, .notice, .warn


Sample Usage

I get the most mileage from this class when validating forms. Here is a quick example.

$validation = new Validate($_POST);
$validation->rule(.....) <-- Add rules

if( $validation->check() )
{
    // Validation passed
    Message::success('Form Success!');
    // OR -> Message::set(Message::SUCCESS, 'Form Success!');
}
else
{
    // Validation failed
    Message::error($validation->errors('_form_');
    // OR -> Message::set(Message::ERROR, $validation->errors('_form_'));
}
Something went wrong with that request. Please try again.