PHP code example of f4php / hookmanager
1. Go to this page and download the library: Download f4php/hookmanager library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
f4php / hookmanager example snippets
/*
* The first step is to register a hook handler for an arbitrary hook name.
*
* HookManager er::addHook('hook name', function (array $context): bool {
// do something useful
return true;
});
// ...
/*
* Once registered, hooks may be invoked (triggered) anywhere in the code.
*
* This call will return an array composed of return values
* produced by all registered handlers if present, or an empty
* array otherwise.
*/
HookManager::triggerHook('hook name', ['context' => null]); // returns: [ 0 => true ]