-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBootstrap.php
90 lines (73 loc) · 2.93 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
<?php
namespace ProVallo\Plugins\Savas;
use ProVallo\Core;
class Bootstrap extends \ProVallo\Components\Plugin\Bootstrap
{
public function install ()
{
$this->installDB();
$this->createConfig();
return true;
}
public function update ($previousVersion)
{
$this->installDB();
$this->createConfig();
return true;
}
protected function createConfig ()
{
Core::di()->get('backend.config')->create($this, [
'domainID' => [
'label' => 'Domain',
'type' => 'select',
'store' => [
'type' => 'remote',
'model' => 'domain',
'displayField' => 'label',
'valueField' => 'id'
],
'description' => 'On which domain should the store be available?'
],
'search_api' => [
'label' => 'Enable Search API',
'type' => 'checkbox'
]
]);
}
public function execute ()
{
if (Core::instance()->getApi() === CORE::API_WEB)
{
$config = Core::di()->get('backend.config')->get($this);
$domainID = Core::di()->get('frontend.domain')->getAlternativeID();
if ($config['domainID'] === $domainID)
{
require_once $this->getPath() . '/vendor/autoload.php';
Core::events()->subscribe('core.route.register', function() {
$this->registerController('Frontend', 'Index');
$this->registerController('Frontend', 'User');
$this->registerController('Frontend', 'Application');
$this->registerController('Frontend', 'Channel');
$this->registerController('Frontend', 'Platform');
$this->registerController('Frontend', 'Release');
$this->registerController('Frontend', 'File');
$this->registerController('Frontend', 'Token');
Core::instance()->any('/api/v1/download/{filename}', function () {
require_once __DIR__ . '/Controllers/Frontend/ApiController.php';
return Core::dispatcher()->dispatch('frontend:Api:download', []);
});
$this->registerController('Frontend', 'Api', false);
Core::instance()->any('/api/v1/[{action}]', 'frontend:Api:{action}');
Core::instance()->any('/', 'frontend:Index:index');
});
}
}
}
public static function getConfig ()
{
$plugin = Core::plugins()->get('Savas');
$config = Core::di()->get('backend.config')->get($plugin);
return $config;
}
}