Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/goliatone/emb-notices

Kohana flash notices module.
https://github.com/goliatone/emb-notices

Last synced: 4 days ago
JSON representation

Kohana flash notices module.

Awesome Lists containing this project

README

        

#Notice

The **Notice** module enables to manage application's notifications.

It has a simple api and a light weight implementation, that allows for notice queuing and grouping.
The rendering of the notices is decoupled from the module and fully customizable.

To set a notice, usually from one of your controllers, you simple call `Notice::add`

$level = Notice::ERROR;
$header = 'Validation Error';
$message = 'You need to provide a valid email.';
$notice_group = 'post.create';
Notice::add(Notice::ERROR, $message,$header, $notice_group);

To render a notice, usually inside one of your views or partials, you can check for an specific group:

if(Notice::queued('post.create')) echo Notice::render('post.create');

Or just go ahead, and render all notices:

if(Notice::queued()) echo Notice::render();

Which, in turn will call the default basic view:

if (! empty($messages)) {
$output = '';
foreach ($messages as $type => $message) {
foreach ($message as $notice) {
$output .= '

';
$output .= '

'.$notice->header.'

';
$output .= '

'.$notice->message.'

';
$output .= '
';
}
}
echo $output;
}

###Notice Levels

There are four default notice levels, and four shortcut methods to call them.
This way we don't have to specify the level like we do with `Notice::add`

Notice::notice($message,$header, $notice_group);
Notice::success($message,$header, $notice_group);
Notice::warn($message,$header, $notice_group);
Notice::error($message,$header, $notice_group);