-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBootstrap.php
More file actions
105 lines (88 loc) · 2.94 KB
/
Bootstrap.php
File metadata and controls
105 lines (88 loc) · 2.94 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
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
98
99
100
101
102
103
104
105
<?php
namespace ProVallo\Plugins\Forms;
use Favez\Mvc\Event\Arguments;
use ProVallo\Core;
use ProVallo\Plugins\Forms\Components\View\FormExtension;
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, [
'recaptcha.enabled' => [
'type' => 'checkbox',
'label' => 'Use reCAPTCHA',
'value' => false
],
'recaptcha.site_key' => [
'type' => 'text',
'label' => 'reCAPTCHA SiteKey',
'value' => ''
],
'recaptcha.secret_key' => [
'type' => 'text',
'label' => 'reCAPTCHA SecretKey',
'value' => ''
]
]);
}
public function execute ()
{
require_once __DIR__ . '/vendor/autoload.php';
if (Core::instance()->getApi() === Core::API_WEB)
{
// Register custom controllers
$this->registerController('Backend', 'Form');
$this->registerController('Backend', 'Submission');
$this->registerController('Frontend', 'Form');
// Register view extensions
Core::events()->subscribe('core.view.init', function (Arguments $args)
{
/** @var \Favez\Mvc\View\View $view */
$view = $args->get(0);
$view->engine()->addExtension(new FormExtension());
});
}
if (Core::instance()->getApi() === Core::API_CONSOLE)
{
// Register backend extensions
Core::events()->subscribe('backend.register', function ()
{
return [
$this
];
});
// Register frontend resources
Core::events()->subscribe('frontend.register.less', function ()
{
return [
path($this->getPath(), 'Views/_resources/less/all.less')
];
});
Core::events()->subscribe('frontend.register.javascript', function ()
{
return [
path($this->getPath(), 'Views/_resources/js/jquery.min.js'),
path($this->getPath(), 'Views/_resources/js/jquery.form.js')
];
});
}
}
public static function getConfig ()
{
$plugin = Core::plugins()->get('Forms');
$config = Core::di()->get('backend.config')->get($plugin);
return $config;
}
}