2017 © Pedro Peláez
 

kohana-module pigeonhole

Flash message management for kohana

image

ingenerator/pigeonhole

Flash message management for kohana

  • Tuesday, February 13, 2018
  • by acoulton
  • Repository
  • 2 Watchers
  • 0 Stars
  • 3,704 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 5 % Grown

The README.md

Pigeonhole - clean flash message management for Kohana

License Master Build Status Latest Stable Version Total Downloads Latest Unstable Version, (*1)

Pigeonhole is a simple flash messaging library for Kohana., (*2)

Installation

Add config to your composer.json and run composer update to install it. Note that we recommend forcing all kohana modules into your standard composer vendor directory. If you want to use the old-style MODPATH, then don't use the "extra" composer config option., (*3)

{
  "require": {"ingenerator/pigeonhole": "0.1.*@dev"},
  "extra":   {"installer-paths":{"vendor/{$vendor}/{$name}":["type:kohana-module"]}}
}

In your bootstrap, add it to your modules list:, (*4)

    Kohana::modules(array(
        'pigeonhole' => BASEDIR.'vendor/ingenerator/pigeonhole' 
        // Or MODPATH.'pigeonhole' if using old-style kohana paths
    );

Basic Usage

To set a simple string message:, (*5)

class Controller_Something {
    public function action_message() {
        $message    = new \Ingenerator\Pigenohole\Message(
            'Look Out!', 
            'There\'s a monster behind you', 
            \Ingenerator\Pigeonhole\Message::DANGER
        );
        $pigeonhole = new \Ingenerator\Pigeonhole\Pigeonhole(Session::instance());
        $pigeonhole->add($message);
        $this->redirect('/');
    }
}

For the simplest way to render messages using Kohana's native view rendering:, (*6)

/// views/template/global.php
<html>
<head>
  <link rel="stylesheet" 
        href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
</head>
<body>
    <?=View::factory(
        'pigeonhole/messages', 
        array('pigeonhole' => new \Ingenerator\Pigeonhole\Pigeonhole(Session::instance()))
    )->render();?>
</body>

Note that we actually recommend you use view models and manage the pigeonhole class and nested view outside the template. It's obviously easy to render the messages to support any CSS setup, we render for bootstrap by default., (*7)

Message types

In addition to simple string messages, we provide built-in handling for some additional common message types., (*8)

Validation messages

Formats the output of kohana validation errors with a given message file:, (*9)

$validation = Validation::factory($post)->rule('email', 'not_empty');
$message = new \Ingenerator\Pigeonhole\Message\ValidationMessage(
    $validation, 
    'forms/login'
);

Kohana messages

Looks up the title and message in a kohana messages file and replaces any provided parameters:, (*10)

/// APPPATH/messages/actions.php
return array(
    'signed_in' => array(
      'title'   => 'Welcome',
      'message' => ':email, you are now logged in'
    )
);

/// Controller
$message = new \Ingenerator\Pigeonhole\Message\KohanaMessage(
    'actions', 
    'signed_in', 
    array(':email' => $email), 
    \Ingenerator\Pigeonhole\Message::SUCCESS
);

Testing and developing

pigeonhole has a suite of PhpSpec specifications. You'll need a skeleton Kohana application to run them, you can use koharness to create one. See travis.yml for the build steps required., (*11)

Contributions will only be accepted if they are accompanied by well structured specs. Installing with composer should get you everything you need to work on the project., (*12)

License

pigeonhole is copyright 2014 inGenerator Ltd and released under the BSD license., (*13)

The Versions

13/02 2018

dev-master

9999999-dev https://github.com/ingenerator/pigeonhole

Flash message management for kohana

  Sources   Download

BSD BSD-3-Clause

The Requires

 

The Development Requires

kohana

02/03 2017

v0.1.1

0.1.1.0 https://github.com/ingenerator/pigeonhole

Flash message management for kohana

  Sources   Download

BSD

The Requires

 

The Development Requires

kohana

27/08 2014

v0.1.0

0.1.0.0 https://github.com/ingenerator/pigeonhole

Flash message management for kohana

  Sources   Download

BSD

The Requires

 

The Development Requires

kohana