修复 blade hook 优先级被覆盖导致插件失效
This commit is contained in:
parent
9529d68d38
commit
e1a4d1b3cc
|
|
@ -49,10 +49,10 @@ class Hook
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $hook
|
* @param string $hook
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @param callable|null $callback
|
* @param callable|null $callback
|
||||||
* @param string $htmlContent
|
* @param string $htmlContent
|
||||||
* @return string|void|null
|
* @return string|void|null
|
||||||
*/
|
*/
|
||||||
public function getHook(string $hook, array $params = [], callable $callback = null, string $htmlContent = '')
|
public function getHook(string $hook, array $params = [], callable $callback = null, string $htmlContent = '')
|
||||||
|
|
@ -64,12 +64,11 @@ class Hook
|
||||||
return $this->get($hook, $params, $callback, $htmlContent);
|
return $this->get($hook, $params, $callback, $htmlContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $hook
|
* @param string $hook
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @param callable|null $callback
|
* @param callable|null $callback
|
||||||
* @param string $htmlContent
|
* @param string $htmlContent
|
||||||
* @return string|void|null
|
* @return string|void|null
|
||||||
*/
|
*/
|
||||||
public function getWrapper(string $hook, array $params = [], callable $callback = null, string $htmlContent = '')
|
public function getWrapper(string $hook, array $params = [], callable $callback = null, string $htmlContent = '')
|
||||||
|
|
@ -114,11 +113,15 @@ class Hook
|
||||||
$priority = null;
|
$priority = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($this->watch[$hook][$priority])) {
|
||||||
|
$priority++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->watch[$hook][$priority] = [
|
$this->watch[$hook][$priority] = [
|
||||||
'function' => $function,
|
'function' => $function,
|
||||||
'caller' => [
|
'caller' => [
|
||||||
//'file' => $caller['file'],
|
'file' => $caller['file'],
|
||||||
//'line' => $caller['line'],
|
'line' => $caller['line'],
|
||||||
'class' => Arr::get($caller, 'class'),
|
'class' => Arr::get($caller, 'class'),
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
@ -192,7 +195,7 @@ class Hook
|
||||||
* Return a new callback object.
|
* Return a new callback object.
|
||||||
*
|
*
|
||||||
* @param callable $callback function
|
* @param callable $callback function
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
*
|
*
|
||||||
* @return Callback
|
* @return Callback
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ class HookServiceProvider extends ServiceProvider
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
$this->bootHookDirectives();
|
$this->bootHookDirectives();
|
||||||
|
|
@ -33,7 +32,7 @@ class HookServiceProvider extends ServiceProvider
|
||||||
protected function bootHookDirectives()
|
protected function bootHookDirectives()
|
||||||
{
|
{
|
||||||
Blade::directive('hook', function ($parameter) {
|
Blade::directive('hook', function ($parameter) {
|
||||||
$parameter = trim($parameter, '()');
|
$parameter = trim($parameter, '()');
|
||||||
$parameters = explode(',', $parameter);
|
$parameters = explode(',', $parameter);
|
||||||
|
|
||||||
$name = trim($parameters[0], "'");
|
$name = trim($parameters[0], "'");
|
||||||
|
|
@ -51,7 +50,6 @@ class HookServiceProvider extends ServiceProvider
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加 blade wrapper hook 标签
|
* 添加 blade wrapper hook 标签
|
||||||
*
|
*
|
||||||
|
|
@ -60,9 +58,9 @@ class HookServiceProvider extends ServiceProvider
|
||||||
protected function bootWrapperHookDirectives()
|
protected function bootWrapperHookDirectives()
|
||||||
{
|
{
|
||||||
Blade::directive('hookwrapper', function ($parameter) {
|
Blade::directive('hookwrapper', function ($parameter) {
|
||||||
$parameter = trim($parameter, '()');
|
$parameter = trim($parameter, '()');
|
||||||
$parameters = explode(',', $parameter);
|
$parameters = explode(',', $parameter);
|
||||||
$name = trim($parameters[0], "'");
|
$name = trim($parameters[0], "'");
|
||||||
|
|
||||||
return ' <?php
|
return ' <?php
|
||||||
$__hook_name="' . $name . '";
|
$__hook_name="' . $name . '";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue