TITAN Library for PHP5  5.6.0
Web Software Development Kit for PHP5
mediator Class Reference

Titan Mediator-Method Hook Management Class. More...

Public Member Functions

 create_hook ($hook)
 
 create_hooks (array $hooks)
 
 add_filter ($hook,\tl\core\loadable $filter)
 
 add_filters ($hook, array $filters)
 
 add_action ($hook,\tl\core\loadable $action, $priority=10)
 
 add_actions ($hook, array $actions, $priority=10)
 
 run_filter ($hook, $parameter)
 
 run_action ($hook,...$params)
 
 hook_exists ($hook)
 
 filter_exists ($hook)
 
 action_exists ($hook)
 

Detailed Description

Titan Mediator-Method Hook Management Class.

Class: \tl\core\plugin\mediator

Author
James E. Bush work@.nosp@m.bush.nosp@m..cc
Version
5.6.0

Description:

$mediator is the global mediator object.

Example:

To register an action hook, simply call $mediator->add_action();

global $mediator;
$mediator->add_action('before_order_add_item', new \tl\core\loadable('', 'myaction'));
$mediator->add_filter('save_order_comments', new \tl\core\loadable('', 'myfilter'));

or

global $mediator;
$mediator->add_action('before_order_add_item', new \tl\core\loadable('myclass', 'myaction'));
$mediator->add_filter('save_order_comments', new \tl\core\loadable('myclass', 'myfilter'));

Do not setup parameters with \tl\core\loadable, the parameters to the original method will be passed to your loadable callback.


Member Function Documentation

create_hook (   $hook)

Create a hook, so plugins can attach loadable functions to hooks

Parameters
string$hookThe hook name
Returns
integer The number of hooks created
create_hooks ( array  $hooks)

Create multiple hooks

Parameters
array$hooksAn array of hook names
Returns
integer The number of hooks created
add_filter (   $hook,
\tl\core\loadable  $filter 
)

Register a loadable filter function to a hook

Parameters
string$hookThe hook name
loadable$filterThe filter loadable function to register
Returns
integer The number of filters registered (0 or 1)
add_filters (   $hook,
array  $filters 
)

Register an array of loadable filter functions to a hook

Parameters
string$hookThe hook name
array$filtersThe array of loadable filter functions to register
Returns
integer The number of filters registered
add_action (   $hook,
\tl\core\loadable  $action,
  $priority = 10 
)

Register a loadable action function to a hook

Parameters
string$hookThe hook name
loadable$actionThe loadable action function to register
integer$priority(optional) hook action priority. Actions are executed in order by priorty. (default) 10
Returns
integer The number of actions registered (0 or 1)
add_actions (   $hook,
array  $actions,
  $priority = 10 
)

Register an array of loadable action functions to a hook

Parameters
string$hookThe hook name
array$actionsThe array of loadable action functions to register
integer$priority(optional) hook action priority. Actions are executed in order by priorty. (default) 10
Returns
integer The number of actions registered
run_filter (   $hook,
  $parameter 
)

Run a filter hook event

Parameters
string$hookThe hook to process
mixed$parameterA parameter passed to each hook filter
Returns
mixed The processed parameter
run_action (   $hook,
  $params 
)

Run an action hook event

Parameters
string$hookThe hook to process
mixed$paramsParameters passed to each hook action
Returns
integer The number of actions executed
hook_exists (   $hook)

Determine if a hook exists

Parameters
string$hookThe hook to check
Returns
boolean
filter_exists (   $hook)

Determine if a filter exists for a hook

Parameters
string$hookThe hook to check
Returns
boolean
action_exists (   $hook)

Determine if an action exists for a hook

Parameters
string$hookThe hook to check
Returns
boolean

The documentation for this class was generated from the following file: