tomas/message

Message handling plugin

v1.0 2016-02-19 13:21 UTC

This package is not auto-updated.

Last update: 2024-09-20 18:36:08 UTC


README

Build Status Scrutinizer Code Quality Code Coverage

This is a simple Message plugin that will store message via Session and display it for a given interval. Support for several message bubbles.

  1. Include
  • message.js
  • message.css
  • Message.php
    • Include the file wherever you may want to start a message and also where you want to output message.

##Simple SET and GET

  1. setMessage(your message)
  • accepts array only
  • ['type', 'msg']
    • Type either "ok" or "error"
    • Msg the wanted message to display
  1. getMessage() *outputs the message

##Use with Anax-MVC

  1. Js and Css files
  • message.js
    • put into webroot/js
    • include that JS-file in your Theme
  • message.css
    • put into webroot/css
    • include that CSS-file in your Theme
  1. PHP file
  • Change Namespace in Message.php file
  • Load Message.php in CDIFactory
  • Create custom CDIFactory
<?php

namespace -Your namespace-

use Anax\DI\CDIFactoryDefault;
use tomas\Message\Message;

class CDIFactory extends CDIFactoryDefault
{
    public function __construct()
    {
        parent::__construct();

        $this->set('message', function() {
            $message = new Message();
            return $message;
        });
    }
}
?>
  1. Change file "config_with_app.php"
  • Change to CDIFactory instead of default
  • Add $app->session();
  1. index.php (or choosen router)
  • furthest down, under "$app->theme->render();" add "$app->message->getMessage()"

Drop me a mail tomas.sjosten@gmail.com if you want to give me some feedback.