-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bootstrap.php
97 lines (82 loc) · 2.34 KB
/
Bootstrap.php
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
declare(strict_types=1);
namespace Plugin\MonduPayment;
use JTL\Events\Dispatcher;
use JTL\Link\LinkInterface;
use JTL\Plugin\Bootstrapper;
use JTL\Shop;
use JTL\Smarty\JTLSmarty;
use Plugin\MonduPayment\Src\Services\InstallService;
use Plugin\MonduPayment\Src\Services\OrderServices\AbstractOrderAdditionalCostsService;
use Plugin\MonduPayment\Src\Services\OrderServices\OrderAdditionalCostsService;
use Plugin\MonduPayment\Src\Services\RoutesService;
/**
* Class Bootstrap
* @package Plugin\MonduPayment
*/
class Bootstrap extends Bootstrapper
{
/**
* @inheritdoc
*/
public function boot(Dispatcher $dispatcher)
{
parent::boot($dispatcher);
$this->registerServices();
}
/**
* @inheritdoc
*/
public function installed()
{
parent::installed();
$withInstall = new InstallService;
$withInstall->install();
}
/**
*
* it's migrate database tables when plugin
*/
public function enabled()
{
}
public function uninstalled(bool $deleteData = false)
{
if ($deleteData === true) {
$deleteTables = new InstallService;
$deleteTables->unInstall();
}
}
/**
*
* writing adminpanel routes for retriving data from database
* @return string
*/
public function renderAdminMenuTab(string $tabName, int $menuID, JTLSmarty $smarty): string
{
$request = $_REQUEST;
$render = new AdminRender($this->getPlugin());
return $render->renderPage($tabName, $smarty, $request);
}
/**
* writing frontend routes for retrieving data from database
*/
public function prepareFrontend(LinkInterface $link, JTLSmarty $smarty): bool
{
parent::prepareFrontend($link, $smarty);
$routes = new RoutesService;
$routes->frontEndRoutes($this->getPlugin());
return true;
}
protected function registerServices(): void
{
$container = Shop::Container();
try {
$container->setSingleton(AbstractOrderAdditionalCostsService::class, function () {
return new OrderAdditionalCostsService();
});
} catch (\Exception $e) {
// Silence
}
}
}