nabeghe/hooker
最新稳定版本:v0.3.3
Composer 安装命令:
composer require nabeghe/hooker
包简介
A simple hook system library (actions and filters) based on Symfony EventDispatcher.
关键字:
README 文档
README
A simple hook system library (actions and filters) based on Symfony EventDispatcher.
🫡 Usage
🚀 Installation
You can install the package via composer:
composer require nabeghe/hooker
Examples
Action
require 'vendor/autoload.php'; use Nabeghe\Hooker\Hooker; use Nabeghe\Hooker\Hook; $hooker = new Hooker(); $hooker->setDefaultArgToHooks('protocol', 'https://'); $hooker->listen('your_custom_action_name', function (Hook $action) { echo $action['protocol'].$action['url'].PHP_EOL; }, 2); // priority = 2 $hooker->action('your_custom_action_name', ['url' => 'https://github.com/nabeghe/hooker']);
Filter:
require 'vendor/autoload.php'; use Nabeghe\Hooker\Hooker; use Nabeghe\Hooker\Hook; $hooker = new Hooker(); $hooker->listen('your_custom_filter_name', function (Hook $filter) { if ($filter->getValue() === null) { $filter->setValue(8 + $filter['default']); } }); $value = $hooker->filter('your_custom_filter_name', null, ['default' => 5]); echo $value; // 13
📖 License
Licensed under the MIT license, see LICENSE.md for details.
统计信息
- 总下载量: 51
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-19