add header menu plugin demo
This commit is contained in:
parent
421e51a092
commit
0a7277b673
|
|
@ -5,6 +5,7 @@ use Beike\Models\AdminUser;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Illuminate\Contracts\Auth\Authenticatable;
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
use TorMorten\Eventy\Facades\Eventy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取后台设置到 settings 表的值
|
* 获取后台设置到 settings 表的值
|
||||||
|
|
@ -299,3 +300,31 @@ function create_directories($directoryPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加 Filter
|
||||||
|
*
|
||||||
|
* @param $hook
|
||||||
|
* @param $callback
|
||||||
|
* @param int $priority
|
||||||
|
* @param int $arguments
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function add_filter($hook, $callback, int $priority = 20, int $arguments = 1)
|
||||||
|
{
|
||||||
|
return Eventy::addFilter($hook, $callback, $priority, $arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加 Action
|
||||||
|
*
|
||||||
|
* @param $hook
|
||||||
|
* @param $callback
|
||||||
|
* @param int $priority
|
||||||
|
* @param int $arguments
|
||||||
|
*/
|
||||||
|
function add_action($hook, $callback, int $priority = 20, int $arguments = 1)
|
||||||
|
{
|
||||||
|
Eventy::addAction($hook, $callback, $priority, $arguments);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* bootstrap.php
|
|
||||||
*
|
|
||||||
* @copyright 2022 opencart.cn - All Rights Reserved
|
|
||||||
* @link http://www.guangdawangluo.com
|
|
||||||
* @author Edward Yang <yangjin@opencart.cn>
|
|
||||||
* @created 2022-07-20 15:35:59
|
|
||||||
* @modified 2022-07-20 15:35:59
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Plugin\BKStripe;
|
|
||||||
|
|
||||||
use TorMorten\Eventy\Facades\Eventy;
|
|
||||||
|
|
||||||
class Bootstrap
|
|
||||||
{
|
|
||||||
public function boot()
|
|
||||||
{
|
|
||||||
// dump(__CLASS__, __METHOD__, __FUNCTION__);
|
|
||||||
Eventy::addFilter('header.categories', function($data) {
|
|
||||||
// dump($data);
|
|
||||||
return $data;
|
|
||||||
}, 20, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* bootstrap.php
|
||||||
|
*
|
||||||
|
* @copyright 2022 opencart.cn - All Rights Reserved
|
||||||
|
* @link http://www.guangdawangluo.com
|
||||||
|
* @author Edward Yang <yangjin@opencart.cn>
|
||||||
|
* @created 2022-07-20 15:35:59
|
||||||
|
* @modified 2022-07-20 15:35:59
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Plugin\HeaderMenu;
|
||||||
|
|
||||||
|
class Bootstrap
|
||||||
|
{
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
add_filter('header.categories', function ($data) {
|
||||||
|
$data[] = [
|
||||||
|
'name' => '插件链接',
|
||||||
|
'url' => 'https://www.google.com',
|
||||||
|
'children' => [
|
||||||
|
[
|
||||||
|
"name" => "Google",
|
||||||
|
"url" => "https://www.google.com",
|
||||||
|
], [
|
||||||
|
"name" => "百度",
|
||||||
|
"url" => "https://www.baidu.com",
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
return $data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"code": "header_menu",
|
||||||
|
"name": "首页菜单Demo",
|
||||||
|
"description": "修改首页菜单插件",
|
||||||
|
"type": "view",
|
||||||
|
"version": "v1.0.0",
|
||||||
|
"icon": "https://via.placeholder.com/100x100.png/aabbcc?text=MENU",
|
||||||
|
"author": {
|
||||||
|
"name": "成都光大网络科技有限公司",
|
||||||
|
"email": "yangjin@opencart.cn"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue