统一hook命名
add_filter => add_hook_filter add_action => add_hook_action blade_hook => add_hook_blade wrapperhook => hookwrapper endwrapperhook => endhookwrapper
This commit is contained in:
parent
4d6c89cf6c
commit
33644b40c9
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 ' <?php
|
||||
$__definedVars = (get_defined_vars()["__data"]);
|
||||
if (empty($__definedVars))
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Bootstrap
|
|||
*/
|
||||
private function addLatestProducts()
|
||||
{
|
||||
add_filter('menu.content', function ($data) {
|
||||
add_hook_filter('menu.content', function ($data) {
|
||||
$data[] = [
|
||||
'name' => 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 = '<span class="badge" style="background-color: #FF4D00; color: #ffffff; border-color: #FF4D00">Hot</span>';
|
||||
return $badge . $output;
|
||||
});
|
||||
|
||||
blade_hook('product.detail.brand', function ($callback, $output, $data) {
|
||||
add_hook_blade('product.detail.brand', function ($callback, $output, $data) {
|
||||
return $output . '<div class="d-flex"><span class="title text-muted">Brand 2:</span>品牌 2</div>';
|
||||
});
|
||||
|
||||
blade_hook('product.detail.buy.after', function ($callback, $output, $data) {
|
||||
add_hook_blade('product.detail.buy.after', function ($callback, $output, $data) {
|
||||
$view = view('LatestProducts::shop.product_button')->render();
|
||||
return $output . $view;
|
||||
});
|
||||
|
|
@ -99,7 +99,7 @@ class Bootstrap
|
|||
*/
|
||||
private function modifyAdminProductEdit()
|
||||
{
|
||||
blade_hook('admin.product.edit.extra', function ($callback, $output, $data) {
|
||||
add_hook_blade('admin.product.edit.extra', function ($callback, $output, $data) {
|
||||
$view = view('LatestProducts::admin.product.edit_extra_field', $data)->render();
|
||||
return $output . $view;
|
||||
}, 1);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class Bootstrap
|
|||
*/
|
||||
private function addSocialData()
|
||||
{
|
||||
add_filter('login.social.buttons', function ($buttons) {
|
||||
add_hook_filter('login.social.buttons', function ($buttons) {
|
||||
$providers = plugin_setting('social.setting');
|
||||
if (empty($providers)) {
|
||||
return $buttons;
|
||||
|
|
|
|||
|
|
@ -76,12 +76,12 @@
|
|||
{{-- <x-admin-form-input name="video" title="视频" :value="old('video', $product->video ?? '')" /> --}}
|
||||
<x-admin-form-input name="position" :title="__('common.sort_order')" :value="old('position', $product->position ?? '0')" />
|
||||
|
||||
@wrapperhook('admin.product.edit.brand')
|
||||
@hookwrapper('admin.product.edit.brand')
|
||||
<x-admin::form.row :title="__('admin/brand.index')">
|
||||
<input type="text" value="{{ $product->brand->name ?? '' }}" id="brand-autocomplete" class="form-control wp-400 " />
|
||||
<input type="hidden" name="brand_id" value="{{ old('brand_id', $product->brand_id ?? '') }}" />
|
||||
</x-admin::form.row>
|
||||
@endwrapperhook
|
||||
@endhookwrapper
|
||||
|
||||
<x-admin-form-select :title="__('admin/tax_class.index')" name="tax_class_id" :value="old('tax_class_id', $product->tax_class_id ?? '')" :options="$tax_classes" key="id" label="title" />
|
||||
<x-admin-form-switch name="active" :title="__('common.status')" :value="old('active', $product->active ?? 1)" />
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<div class="top-wrap">
|
||||
<div class="container d-flex justify-content-between align-items-center">
|
||||
<div class="left d-flex align-items-center">
|
||||
@wrapperhook('header.top.currency')
|
||||
@hookwrapper('header.top.currency')
|
||||
<div class="dropdown">
|
||||
<a class="btn dropdown-toggle ps-0" href="javascript:void(0)" role="button" id="currency-dropdown" data-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
|
|
@ -34,9 +34,9 @@
|
|||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endwrapperhook
|
||||
@endhookwrapper
|
||||
|
||||
@wrapperhook('header.top.language')
|
||||
@hookwrapper('header.top.language')
|
||||
<div class="dropdown">
|
||||
<a class="btn dropdown-toggle" href="javascript:void(0)" role="button" id="language-dropdown" data-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
|
|
@ -51,14 +51,14 @@
|
|||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endwrapperhook
|
||||
@endhookwrapper
|
||||
</div>
|
||||
|
||||
@if (system_setting('base.telephone', ''))
|
||||
<div class="right nav">
|
||||
@wrapperhook('header.top.telephone')
|
||||
@hookwrapper('header.top.telephone')
|
||||
<span class="px-2"><i class="bi bi-telephone-forward me-2"></i> {{ system_setting('base.telephone') }}</span>
|
||||
@endwrapperhook
|
||||
@endhookwrapper
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
|
@ -66,11 +66,11 @@
|
|||
|
||||
<div class="header-content d-none d-lg-block py-3">
|
||||
<div class="container navbar-expand-lg">
|
||||
@wrapperhook('header.menu.logo')
|
||||
@hookwrapper('header.menu.logo')
|
||||
<div class="logo"><a href="{{ shop_route('home.index') }}">
|
||||
<img src="{{ image_origin(system_setting('base.logo')) }}" class="img-fluid"></a>
|
||||
</div>
|
||||
@endwrapperhook
|
||||
@endhookwrapper
|
||||
<div class="menu-wrap">
|
||||
@if (!is_mobile())
|
||||
@include('shared.menu-pc')
|
||||
|
|
@ -78,7 +78,7 @@
|
|||
</div>
|
||||
<div class="right-btn">
|
||||
<ul class="navbar-nav flex-row">
|
||||
@wrapperhook('header.menu.icon')
|
||||
@hookwrapper('header.menu.icon')
|
||||
<li class="nav-item"><a href="#offcanvas-search-top" data-bs-toggle="offcanvas"
|
||||
aria-controls="offcanvasExample" class="nav-link"><i class="iconfont"></i></a></li>
|
||||
<li class="nav-item"><a href="{{ shop_route('account.wishlist.index') }}" class="nav-link"><i
|
||||
|
|
@ -110,7 +110,7 @@
|
|||
@endauth
|
||||
</ul>
|
||||
</li>
|
||||
@endwrapperhook
|
||||
@endhookwrapper
|
||||
<li class="nav-item">
|
||||
<a class="nav-link position-relative" {{ !equal_route('shop.carts.index') ? 'data-bs-toggle=offcanvas' : '' }}
|
||||
href="{{ !equal_route('shop.carts.index') ? '#offcanvas-right-cart' : 'javascript:void(0);' }}" role="button"
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@
|
|||
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="peoduct-info">
|
||||
@wrapperhook('product.detail.name')
|
||||
@hookwrapper('product.detail.name')
|
||||
<h1 class="mb-4 product-name">{{ $product['name'] }}</h1>
|
||||
@endwrapperhook
|
||||
@endhookwrapper
|
||||
<div class="price-wrap d-flex align-items-end">
|
||||
<div class="new-price fs-1 lh-1 fw-bold me-2">@{{ product.price_format }}</div>
|
||||
<div class="old-price text-muted text-decoration-line-through" v-if="product.price != product.origin_price && product.origin_price !== 0">
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="stock-and-sku mb-4">
|
||||
@wrapperhook('product.detail.quantity')
|
||||
@hookwrapper('product.detail.quantity')
|
||||
<div class="d-flex">
|
||||
<span class="title text-muted">{{ __('product.quantity') }}:</span>
|
||||
<div :class="product.quantity > 0 ? 'text-success' : 'text-secondary'">
|
||||
|
|
@ -70,24 +70,24 @@
|
|||
<template v-else>{{ __('shop/products.out_stock') }}</template>
|
||||
</div>
|
||||
</div>
|
||||
@endwrapperhook
|
||||
@endhookwrapper
|
||||
|
||||
@if ($product['brand_id'])
|
||||
@wrapperhook('product.detail.brand')
|
||||
@hookwrapper('product.detail.brand')
|
||||
<div class="d-flex">
|
||||
<span class="title text-muted">{{ __('product.brand') }}:</span>
|
||||
<a href="{{ shop_route('brands.show', $product['brand_id']) }}">{{ $product['brand_name'] }}</a>
|
||||
</div>
|
||||
@endwrapperhook
|
||||
@endhookwrapper
|
||||
@endif
|
||||
|
||||
@wrapperhook('product.detail.sku')
|
||||
@hookwrapper('product.detail.sku')
|
||||
<div class="d-flex"><span class="title text-muted">SKU:</span>@{{ product.sku }}</div>
|
||||
@endwrapperhook
|
||||
@endhookwrapper
|
||||
|
||||
@wrapperhook('product.detail.model')
|
||||
@hookwrapper('product.detail.model')
|
||||
<div class="d-flex" v-if="product.model"><span class="title text-muted">{{ __('shop/products.model') }}:</span> @{{ product.model }}</div>
|
||||
@endwrapperhook
|
||||
@endhookwrapper
|
||||
</div>
|
||||
@if (0)
|
||||
<div class="rating-wrap d-flex">
|
||||
|
|
|
|||
Loading…
Reference in New Issue