在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):jarektkaczyk/hookable开源软件地址(OpenSource Url):https://github.com/jarektkaczyk/hookable开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):Sofa/HookableHooks system for the Eloquent ORM (Laravel 5.2). Hooks are available for the following methods:
and all methods available on the InstallationClone the repo or pull as composer dependency:
UsageIn order to register a hook you use static method Important Due to the fact that PHP will not let you bind a For example see the above example along with the class that encloses our closures in an instance scope that is being used there. Signature for the hook closure is following: function (Closure $next, mixed $payload, Sofa\Hookable\Contracts\ArgumentBag $args) Hooks are resolved via // 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);
} ContributionAll contributions are welcome, PRs must be tested and PSR-2 compliant. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论