Show HOOK in debug bar.
This commit is contained in:
parent
43c7a5461e
commit
46b9ebfa41
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Barryvdh\Debugbar\Facades\Debugbar;
|
||||
use Beike\Hook\Facades\Hook;
|
||||
use Beike\Models\AdminUser;
|
||||
use Beike\Models\Currency;
|
||||
|
|
@ -184,7 +185,7 @@ function type_label($type, $value, array $texts = []): string
|
|||
return PageRepo::getName($value);
|
||||
} elseif ($type == 'page_category') {
|
||||
return PageCategoryRepo::getName($value);
|
||||
} elseif ($type == 'static') {
|
||||
} elseif ($type == 'static') {
|
||||
return trans('shop/' . $value);
|
||||
} elseif ($type == 'custom') {
|
||||
return $text;
|
||||
|
|
@ -529,7 +530,7 @@ function quantity_format($quantity)
|
|||
return round($quantity / 1000, 1) . 'K';
|
||||
}
|
||||
|
||||
return $quantity;
|
||||
return $quantity;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -618,6 +619,10 @@ function create_directories($directoryPath)
|
|||
*/
|
||||
function hook_filter($hookKey, $hookValue): mixed
|
||||
{
|
||||
if (config('app.debug')) {
|
||||
Debugbar::log('HOOK === hook_filter: ' . $hookKey);
|
||||
}
|
||||
|
||||
return Eventy::filter($hookKey, $hookValue);
|
||||
}
|
||||
|
||||
|
|
@ -629,6 +634,9 @@ function hook_filter($hookKey, $hookValue): mixed
|
|||
*/
|
||||
function hook_action($hookKey, $hookValue)
|
||||
{
|
||||
if (config('app.debug')) {
|
||||
Debugbar::log('HOOK === hook_action: ' . $hookKey);
|
||||
}
|
||||
Eventy::action($hookKey, $hookValue);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
namespace Beike\Hook;
|
||||
|
||||
use Barryvdh\Debugbar\Facades\Debugbar;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class Hook
|
||||
|
|
@ -47,6 +48,37 @@ class Hook
|
|||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $hook
|
||||
* @param array $params
|
||||
* @param callable|null $callback
|
||||
* @param string $htmlContent
|
||||
* @return string|void|null
|
||||
*/
|
||||
public function getHook(string $hook, array $params = [], callable $callback = null, string $htmlContent = '')
|
||||
{
|
||||
if (config('app.debug')) {
|
||||
Debugbar::log("HOOK === @hook: {$hook}");
|
||||
}
|
||||
return $this->get($hook, $params, $callback, $htmlContent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $hook
|
||||
* @param array $params
|
||||
* @param callable|null $callback
|
||||
* @param string $htmlContent
|
||||
* @return string|void|null
|
||||
*/
|
||||
public function getWrapper(string $hook, array $params = [], callable $callback = null, string $htmlContent = '')
|
||||
{
|
||||
if (config('app.debug')) {
|
||||
Debugbar::log("HOOK === @hookwrapper: {$hook}");
|
||||
}
|
||||
return $this->get($hook, $params, $callback, $htmlContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop all another hook running.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class HookServiceProvider extends ServiceProvider
|
|||
{
|
||||
$__definedVars = [];
|
||||
}
|
||||
$output = \Hook::get("' . $name . '",["data"=>$__definedVars],function($data) { return null; });
|
||||
$output = \Hook::getHook("' . $name . '",["data"=>$__definedVars],function($data) { return null; });
|
||||
if ($output)
|
||||
echo $output;
|
||||
?>';
|
||||
|
|
@ -78,7 +78,7 @@ class HookServiceProvider extends ServiceProvider
|
|||
$__definedVars = [];
|
||||
}
|
||||
$__hook_content = ob_get_clean();
|
||||
$output = \Hook::get("$__hook_name",["data"=>$__definedVars],function($data) { return null; },$__hook_content);
|
||||
$output = \Hook::getWrapper("$__hook_name",["data"=>$__definedVars],function($data) { return null; },$__hook_content);
|
||||
unset($__hook_name);
|
||||
unset($__hook_content);
|
||||
if ($output)
|
||||
|
|
|
|||
Loading…
Reference in New Issue