-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoot.php
More file actions
41 lines (36 loc) · 1.66 KB
/
Boot.php
File metadata and controls
41 lines (36 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
declare(strict_types=1);
namespace Plugins\MagixMultiText;
use App\Component\Hook\HookManager;
use Magepattern\Component\Tool\SmartyTool;
class Boot
{
private array $targetModules = [
'product' => 'id_product',
'pages' => 'id_pages',
'category' => 'id_cat',
'news' => 'id_news',
'about' => 'id_about'
];
public function register(): void
{
// ==========================================
// 1. HOOKS BACKEND (Administration)
// ==========================================
foreach ($this->targetModules as $module => $idKey) {
HookManager::register("{$module}_edit_tab", 'MagixMultiText', function(array $params) use ($module) {
$smarty = SmartyTool::getInstance('admin');
$smarty->assign('multitext_module', $module);
$file = ROOT_DIR . 'plugins' . DS . 'MagixMultiText' . DS . 'views' . DS . 'admin' . DS . 'hooks' . DS . 'tab_button.tpl';
return $smarty->templateExists($file) ? $smarty->fetch($file) : '';
});
HookManager::register("{$module}_edit_content", 'MagixMultiText', function(array $params) use ($module, $idKey) {
$smarty = SmartyTool::getInstance('admin');
$idModule = $params[$idKey] ?? 0;
$smarty->assign(['multitext_module' => $module, 'multitext_id_module' => $idModule]);
$file = ROOT_DIR . 'plugins' . DS . 'MagixMultiText' . DS . 'views' . DS . 'admin' . DS . 'hooks' . DS . 'tab_content.tpl';
return $smarty->templateExists($file) ? $smarty->fetch($file) : '';
});
}
}
}