定制 kigkonsult/hookmgr 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

kigkonsult/hookmgr

Composer 安装命令:

composer require kigkonsult/hookmgr

包简介

PHP hook callables manager

README 文档

README

Class HookMgr manages PHP hooks

A hook is a (HookMgr) key for invoking callable(s)

A callable can be

  • simple function
  • anonymous function
  • instantiated object+method : [ $object, 'methodName' ]
  • class name and static method : [ 'namespaceClassName', 'methodName' ]
  • instantiated object, class with (magic) __call method : [ $object, 'someMethod' ]
  • class name, class with (magic) __callStatic method : [ 'namespaceClassName', 'someMethod' ]
  • instantiated object, class with (magic) __invoke method : $object

Define a hook with callable

HookMgr::addAction( $hook, $callable );

Invoke callable using hook

$result = HookMgr::apply( $hook );
Methods

HookMgr::addAction( hook, callable )

  • Add single hook with single callable, syntax_only callable check
  • hook string
  • callable callable
  • Throws InvalidArgumentException
  • static

HookMgr::addActions( hook, callables )

  • Add single hook invoking an array of callables
  • Note, if invoked with arguments, arguments are used for all callables
  • hook string
  • callables callable[]
  • Throws InvalidArgumentException
  • static

HookMgr::setActions( actions )

  • Set all hooks, each for invoking single or array of callables
  • actions array *( hook => callable(s) )
  • Throws InvalidArgumentException
  • static

HookMgr::apply( hook [, args ] )

  • Invoke 'hook' action(s), return (last) result
  • hook string
  • args array opt, [ arg1, arg2... ]
    • Opt arguments are used in all hook invokes
    • To use an argument by-reference, use HookMgr::apply( 'hook', [ & $arg ] );
  • Return mixed
  • Throws RuntimeException
  • static

HookMgr::count( hook )

  • Return count of callables for hook, not found return 0
  • hook string
  • Return bool
  • static

HookMgr::exists( hook )

  • Return bool true if hook is set
  • hook string
  • Return bool
  • static

HookMgr::getCallables( hook )

  • Return array callables for hook, not found return []
  • hook string
  • Return callable[]
  • static

HookMgr::getHooks()

  • Return array (string[]) hooks
  • static

HookMgr::init()

  • Clear (remove) all hooks with callables
  • static

HookMgr::remove( hook )

  • Remove single hook with callable(s)
  • hook string
  • static

HookMgr::toString()

  • Return string nice rendered hooks with callable(s)
  • static
Sponsorship

Donation using paypal.me/kigkonsult are appreciated. For invoice, please e-mail.

INSTALL
composer require kigkonsult/hookmgr:dev-master

Composer, in your composer.json:

{
    "require": {
        "kigkonsult/hookmgr": "dev-master"
    }
}

Version 1.4 supports PHP 8, 1.2 7.4, 1.1 7.0.

Composer, acquire access

use Kigkonsult\HookMgr\HookMgr;
...
include 'vendor/autoload.php';

Otherwise , download and acquire..

use Kigkonsult\HookMgr\HookMgr;
...
include 'pathToSource/kigkonsult/HookMgr/autoload.php';
Support

For support go to github.com HookMgr

License

This project is licensed under the LGPLv3 License

统计信息

  • 总下载量: 79
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2020-05-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固