PHP code example of sofa / hookable
1. Go to this page and download the library: Download sofa/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/ */
sofa / 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);
}