PHP code example of bionicmaster / hookable
1. Go to this page and download the library: Download bionicmaster/hookable 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/ */
bionicmaster / hookable example snippets
function (Closure $next, mixed $payload, Sofa\Hookable\Contracts\ArgumentBag $args)
// example hook on getAttribute method:
function ($next, $value, $args)
{
if (/* your condition */) {
// return early
return 'some value'; // or the $value
}
else if (/* other condition */) {
// you may want to mutate the value
$value = strtolower($value);
}
// finally continue calling other hooks
return $next($value, $args);
}