dartmoon / prestashop-tabmanager
用于简化 PrestaShop 后台菜单标签创建的库
v0.1.2
2021-04-17 06:28 UTC
Requires
- dartmoon/prestashop-utils: ^0.1.0
README
一个简单的包,允许您将控制器添加到 PrestaShop 后台菜单。只需定义一个包含所有菜单项的数组,然后让包安装它们。
安装
- 安装包
composer require dartmoon/prestashop-tabmanager
- 在您的模块主类中定义一个名为
menu_tabs
的数组
//... protected $menu_tabs = [ // ]; //...
- 修复模块的
install
和uninstall
方法
//... public function install() { if ( parent::install() && TabManager::install($this->menu_tabs, $this) // && $this->registerHook(...) ) { //... return true; } return false; } public function uninstall() { //... TabManager::uninstallForModule($this); return parent::uninstall(); } //...
使用方法
简单地将所有菜单项添加到 menu_tabs
数组中。
protected $menu_tabs = [ [// This is a parent tab 'name' => 'Parent tab', 'class_name' => 'UNIQUE_TAB_NAME', 'route_name' => '', 'parent_class_name' => '', 'icon' => 'settings', 'visible' => true, ], [ // This a child of the previus tab 'name' => 'Child tab', 'class_name' => 'MySuperClass', // Remember that the controller class name is MySuperClassController, but we need to add it without the suffix "Controller" 'route_name' => '', 'parent_class_name' => 'UNIQUE_TAB_NAME', 'icon' => '', 'visible' => true, ], ];
许可
本项目采用 MIT 许可协议 - 请参阅 LICENSE.md 文件以获取详细信息