handmadeweb / hookable-actions-filters
Installs: 1 660
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Requires
- php: ^7.3||^8.0
Requires (Dev)
- orchestra/testbench: ^6.0||^7.0
README
Hookable Actions And Filters is an Action and Filter library inspired by WordPress's Actions and Filters. This package can be used in Laravel and supports auto discovery, alternatively the package can also be used in any PHP project.
Installation
You can install the package via composer:
composer require handmadeweb/hookable-actions-filters
Usage
Action Examples
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');
Filter Examples
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');
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email michael@rook.net.au instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.