pentagonal / hookable
类似于WordPress使用的可挂钩库
1.0
2016-11-27 17:22 UTC
Requires
- php: >=5.3
Requires (Dev)
- phpunit/phpunit: 4.5.*
This package is not auto-updated.
Last update: 2024-09-26 01:00:06 UTC
README
类似于WordPress使用的可挂钩库
用法
$hook = new \Pentagonal\Hookable\Hookable(); /** * Add Hook into functions example */ function thIsIsOnHookReturn() { global $hooks; /** * .... run the code */ $the_result = array('array_result'); // the returning result return $hook->apply('callback_name', $the_result); } /** * in here * Calling thIsIsOnHookReturn() * will be returning array */ var_dump(thIsIsOnHookReturn()); /** * add filter / action on determined callback */ $hook->add( 'callback_name', // the callback function ($returning_old_result) { $new_result = print_r($returning_result, true); return $new_result; }, 10, // priority 1 // arguments accepted ); /** * in here * Calling thIsIsOnHookReturn() * will be returning string of array printed */ var_dump(thIsIsOnHookReturn());
安装
{ "require": { "pentagonal/hookable": "^1" } }