Giter VIP home page Giter VIP logo

kohana-message's Introduction

Flash\short messaging system for Kohana framework 3.3

Uses cookies to store messages.

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

Usage:

Instance message object:

$message = Message::instance();

Config properties:

Message::$cookie_key = 'flash_message';
// Auto translate with using Kohana::message
Message::$translate = FALSE;
// Filename translation in `messages` folder
Message::$translation_file = 'flash_message';

Constant message types:

Message::ERROR;
Message::NOTICE;
Message::INFO;
Message::SUCCESS;

Sending a message:

$message->set(Message::SUCCESS, 'User info is updated');
// Short version
$message->success('User info is updated');
// Set second param in try for translate, uses Kohana::message
$message->error('Invalid CAPCHA value', TRUE);
// Can send array of messages
$message->error($validation->errors('user'));

Gets a message:

Debug::dump($message->get()); 
// return: array('a' => 'Message A', 'b' => 'Message B')
echo $message->get('a'); 
// Short version
echo $message->a;

Get message type:

echo $message->type();

Checks:

echo (is_array($message->get()) ? 'yes' : 'no');
echo (isset($message->b) ? 'yes' : 'no');

The alternative use - static methods:

Message::set(Message::SUCCESS, 'User info is updated');
Message::notice('Cleanup started');
echo Message::get('a');
echo Message::type();

kohana-message's People

Contributors

wintersilence avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ganquan0910

kohana-message's Issues

It is not issue, only proposal

Hello! How do you think: is Cookie storage good idea, it has space limit max: 4Kb?
Better will be if you will save messages in session
and add into redirect method something like Message::instance()->save();
and on messages loading it will get all messages from Session[key] and remove it from the session (atomar operation)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.