icanboogie / bind-event
将 icanboogie/event 绑定到 ICanBoogie
5.0
2021-05-31 18:13 UTC
Requires
- php: >=7.2
- icanboogie/event: ^4.0
- icanboogie/icanboogie: ^5.0
Requires (Dev)
- phpunit/phpunit: ^8.5
README
icanboogie/bind-event 包将 icanboogie/event 绑定到 ICanBoogie,使用其 自动配置功能。它为在 event
配置片段中定义的事件钩子提供配置合成器,并为 应用程序 实例提供 events
获取器。
<?php namespace ICanBoogie; require 'vendor/autoload.php'; $app = boot(); $app->configs['event']; // obtain the "event" config. $app->events; // obtain an EventCollection instance created with the "event" config.
安装
composer require icanboogie/bind-event
使用 event
配置附加事件钩子
event
配置可用于定义事件钩子。
以下示例演示了应用程序如何将事件钩子附加到在节点保存(或节点子类)时被通知,以及在请求分发期间抛出身份验证异常时。
<?php // config/event.php namespace App; use ICanBoogie; use Icybee; $hooks = Hooks::class . '::'; return [ Icybee\Modules\Nodes\SaveOperation::class . '::process' => $hooks . 'on_nodes_save', ICanBoogie\HTTP\AuthenticationRequired::class . '::rescue' => $hooks . 'on_authentication_required_rescue' ];
持续集成
该项目通过 GitHub actions 持续测试。
行为准则
本项目遵守 贡献者行为准则。通过参与本项目及其社区,您应遵守此准则。
贡献
有关详细信息,请参阅 CONTRIBUTING。
许可
icanboogie/bind-event 采用 BSD-3-Clause 许可。