diff --git a/beike/Helpers.php b/beike/Helpers.php index 2ab77b19..7f87708f 100644 --- a/beike/Helpers.php +++ b/beike/Helpers.php @@ -5,6 +5,7 @@ use Beike\Models\AdminUser; use Illuminate\Support\Str; use Illuminate\Support\Facades\Route; use Illuminate\Contracts\Auth\Authenticatable; +use TorMorten\Eventy\Facades\Eventy; /** * 获取后台设置到 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); +} diff --git a/plugins/BKStripe/Bootstrap.php b/plugins/BKStripe/Bootstrap.php deleted file mode 100644 index 3669e6a3..00000000 --- a/plugins/BKStripe/Bootstrap.php +++ /dev/null @@ -1,26 +0,0 @@ - - * @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); - } -} diff --git a/plugins/HeaderMenu/Bootstrap.php b/plugins/HeaderMenu/Bootstrap.php new file mode 100644 index 00000000..31a56c3d --- /dev/null +++ b/plugins/HeaderMenu/Bootstrap.php @@ -0,0 +1,35 @@ + + * @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; + }); + } +} diff --git a/plugins/HeaderMenu/config.json b/plugins/HeaderMenu/config.json new file mode 100644 index 00000000..76c5491f --- /dev/null +++ b/plugins/HeaderMenu/config.json @@ -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" + } +}