handmadeweb / hookable-actions-filters
1.1.0
2022-03-29 21:44 UTC
Requires
- php: ^7.3||^8.0
Requires (Dev)
- orchestra/testbench: ^6.0||^7.0
README
Hookable Actions And Filters 是一个受 WordPress Actions 和 Filters 启发的 Action 和 Filter 库。此包可以在 Laravel 中使用,并支持自动发现,或者此包也可以在任何 PHP 项目中使用。
安装
您可以通过 composer 安装此包
composer require handmadeweb/hookable-actions-filters
用法
动作示例
use HandmadeWeb\ActionsAndFilters\Action; // Eample function for test function action_test($key){ unset($_GET[$key]); } // Add a action callback to a function by name Action::add('unset', 'action_test'); // Or // Add a action callback to a closure function Action::add('unset', function($key){ action_test($key); // Or this closure function could just do unset($_GET[$key]); }); // Execute the action, which in this example will unset $_GET['foobar'] Action::run('unset', 'foobar');
过滤器示例
use HandmadeWeb\ActionsAndFilters\Filter; // Add a filter callback to a function by name Filter::add('Test', 'ucfirst'); // Add a filter callback to a closure function Filter::add('Test', function($value){ return "{$value} {$value}"; }); // Will return Foobar Foobar Filter::run('Test', 'foobar');
测试
composer test
更新日志
请参阅 更新日志 了解最近更改的详细信息。
贡献
请参阅 贡献指南 了解详情。
安全
如果您发现任何与安全相关的问题,请通过电子邮件 michael@rook.net.au 而不是使用问题跟踪器来报告。
致谢
许可证
MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。