-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mickaël Andrieu
committed
Jul 8, 2019
1 parent
a7431b0
commit aab90d6
Showing
4 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace FOP\Doctrine\Menu; | ||
|
||
use Tab; | ||
use Language; | ||
|
||
/** | ||
* Allows to insert a menu in PrestaShop Back Office | ||
*/ | ||
final class TabManager | ||
{ | ||
/** | ||
* @param $className | ||
* @param $tabName | ||
* @param $moduleName | ||
* @param $parentClassName | ||
* @param $icon | ||
* | ||
* @return Tab | ||
* | ||
* @throws \PrestaShopDatabaseException | ||
* @throws \PrestaShopException | ||
*/ | ||
public static function addTab($className, $tabName, $moduleName, $parentClassName, $icon = null) | ||
{ | ||
$tab = new Tab(); | ||
$tab->active = 1; | ||
$tab->class_name = $className; | ||
$tab->name = array(); | ||
foreach (Language::getLanguages(true) as $lang) { | ||
$tab->name[$lang['id_lang']] = $tabName; | ||
} | ||
|
||
if (!is_null($icon)) { | ||
$tab->icon = $icon; | ||
} | ||
|
||
$tab->id_parent = (int) Tab::getIdFromClassName($parentClassName); | ||
$tab->module = $moduleName; | ||
$tab->add(); | ||
|
||
return $tab; | ||
} | ||
} |