Installation

Add library SimpleHook.php to your application folder and create a configuration file named simplehook.php

Usage

you just have to call the function with the hook's name

$return = simplehook('first');

$return is an array of each functions return , because you can set several functions in a hook.

Configuration

Each hook must have a specific key and you have to add one array for each callable function/method

$config['simplehook'] = array(
    'first' =>  array(
        array(
            'type' => 'library',
            'class' => 'demo',
            'method' => 'test',
            'param' => true
        ),
        array(
            'type' => 'helper',
            'helper' => 'demo',
            'function' => 'demo'
        )
    ),
    'second' => array(
        array(
            'type' => 'rest',
            'url' => 'https://api.twitter.com/1.1/search/tweets.json',
            'method' => 'get',
            'param' => true
        )
    )
);

the hook 'first' call two functions :

  • a library demo and his method test with params
  • a helper function demo without param

Configurations keys

  • type string library|helper|rest|model
  • param boolean true if params send to method/function

if type = library|model

  • class string class name
  • method string method name

if type = helper

  • helper string helper name
  • function string function name

if type = rest

  • url string url to call
  • method string POST|GET