nabeghe/hooker 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-19