Overview

Namespaces

  • Sleepy
  • Module
    • Authentication
    • CSV
    • DB
    • FormBuilder
    • FSDB
    • IP2Country
    • Mailer
    • MobiDetect
    • Navigation
    • StaticCache
  • PHP

Classes

  • Debug
  • Hook
  • Router
  • SM
  • Template

Exceptions

  • RouteNotFound
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Class Hook

Adds Hooks and Filters

You can create modules to hooks by adding php files into the \app\modules\enabled directory.

Usage

// add a hook point
    $content = Hook::addFilter('update_content', $_POST['content']);

    // Add a module to the hook point--in /modules/<moduleName.php>
    function clean_html ($html) {
        $c = htmlentities(trim($html), ENT_NOQUOTES, "UTF-8", false);
        return $c;
    }

    Hook::applyFilter("update_content", "clean_html");

Changelog

Version 1.2

  • Updated privacy prefix (_) for consistency
  • Fixed Hook::_load method for teamsite bug

Version 1.1

  • Added the date section to the documentation

Version 1.0

  • static class pattern fixes
  • multiple module directories
  • crawls subdirectories of module directories
Namespace: Sleepy
License: http://opensource.org/licenses/MIT
Author: Jaime A. Rodriguez hi.i.am.jaime@gmail.com
Version: 1.2
Todo:

devise a better way of passing multiple parameters to hooks, perhaps use objects instead of arrays


Date: July 18, 2016
Located at class.hooks.php
Methods summary
private
# __clone( )

Prevent class from being cloned

Prevent class from being cloned

Private

private
# __construct( )

The constructor is private to ensure we only have one instance

The constructor is private to ensure we only have one instance

Private

private static object
# _initialize( )

Return instance or create initial instance

Return instance or create initial instance

Returns

object

Private

private static
# _load( )

Loads all the modules

Loads all the modules

Private

public static
# applyFilter( string $name, string $function, integer $args,… )

Adds a new filter to a filter-type hook point

Adds a new filter to a filter-type hook point

Parameters

$name
[description]
$function
[description]
$args,…
[description]
public static
# addFilter( mixed $name, string $value )

Adds a new filter-type hook point

Adds a new filter-type hook point

Parameters

$name
[description]
$value
[description]
public static
# doAction( string $name, string $function )

Adds a new function to a action-type hook point

Adds a new function to a action-type hook point

Parameters

$name
Name of filter
$function
Function to call
public static
# addAction( string $name )

Adds a new action-type hook point

Adds a new action-type hook point

Parameters

$name
[description]
Properties summary
private static boolean $_initialized

Has this been initialized?

Has this been initialized?

Private

# false
private static _Filter[] $_filters

An array of filters

An array of filters

Private

# array()
public static string $directories

The directories where the modules are stored

The directories where the modules are stored

# array()
sleepyMUSTACHE v.0.8 API documentation generated by ApiGen