diff --git a/beike/Helpers.php b/beike/Helpers.php index 597012f8..2b5c7916 100644 --- a/beike/Helpers.php +++ b/beike/Helpers.php @@ -636,7 +636,7 @@ function hook_action($hookKey, $hookValue) * @param int $arguments * @return mixed */ -function add_filter($hookKey, $callback, int $priority = 20, int $arguments = 1) +function add_hook_filter($hookKey, $callback, int $priority = 20, int $arguments = 1): mixed { return Eventy::addFilter($hookKey, $callback, $priority, $arguments); } @@ -649,7 +649,7 @@ function add_filter($hookKey, $callback, int $priority = 20, int $arguments = 1) * @param int $priority * @param int $arguments */ -function add_action($hookKey, $callback, int $priority = 20, int $arguments = 1) +function add_hook_action($hookKey, $callback, int $priority = 20, int $arguments = 1) { Eventy::addAction($hookKey, $callback, $priority, $arguments); } @@ -661,7 +661,7 @@ function add_action($hookKey, $callback, int $priority = 20, int $arguments = 1) * @param $callback * @param int $priority */ -function blade_hook($hookKey, $callback, int $priority = 0) +function add_hook_blade($hookKey, $callback, int $priority = 0) { Hook::listen($hookKey, $callback, $priority); } diff --git a/beike/Hook/HookServiceProvider.php b/beike/Hook/HookServiceProvider.php index 4b6f590a..21c5f1a0 100644 --- a/beike/Hook/HookServiceProvider.php +++ b/beike/Hook/HookServiceProvider.php @@ -55,11 +55,11 @@ class HookServiceProvider extends ServiceProvider /** * 添加 blade wrapper hook 标签 * - * @wrapperhook('xxx') --- @endwrapperhook, 将某段代码打包输出再添加 hook 输出 + * @hookwrapper('xxx') --- @endhookwrapper, 将某段代码打包输出再添加 hook 输出 */ protected function bootWrapperHookDirectives() { - Blade::directive('wrapperhook', function ($parameter) { + Blade::directive('hookwrapper', function ($parameter) { $parameter = trim($parameter, '()'); $parameters = explode(',', $parameter); $name = trim($parameters[0], "'"); @@ -70,7 +70,7 @@ class HookServiceProvider extends ServiceProvider ?>'; }); - Blade::directive('endwrapperhook', function () { + Blade::directive('endhookwrapper', function () { return ' trans('LatestProducts::header.latest_products'), "link" => shop_route('latest_products'), @@ -47,23 +47,23 @@ class Bootstrap */ private function modifyHeader() { - blade_hook('header.top.currency', function ($callback, $output, $data) { + add_hook_blade('header.top.currency', function ($callback, $output, $data) { return '货币前' . $output; }); - blade_hook('header.top.language', function ($callback, $output, $data) { + add_hook_blade('header.top.language', function ($callback, $output, $data) { return $output . '语言后'; }); - blade_hook('header.top.telephone', function ($callback, $output, $data) { + add_hook_blade('header.top.telephone', function ($callback, $output, $data) { return '电话前' . $output; }); - blade_hook('header.menu.logo', function ($callback, $output, $data) { + add_hook_blade('header.menu.logo', function ($callback, $output, $data) { return $output . 'Logo后'; }); - blade_hook('header.menu.icon', function ($callback, $output, $data) { + add_hook_blade('header.menu.icon', function ($callback, $output, $data) { $view = view('LatestProducts::shop.header_icon')->render(); return $output . $view; }); @@ -78,16 +78,16 @@ class Bootstrap */ private function modifyProductDetail() { - blade_hook('product.detail.name', function ($callback, $output, $data) { + add_hook_blade('product.detail.name', function ($callback, $output, $data) { $badge = 'Hot'; return $badge . $output; }); - blade_hook('product.detail.brand', function ($callback, $output, $data) { + add_hook_blade('product.detail.brand', function ($callback, $output, $data) { return $output . '