-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBootstrap.php
60 lines (49 loc) · 1.7 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
<?php
class Shopware_Plugins_Frontend_DsnFrontendBlocks_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
public function getVersion() {
$info = json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR .'plugin.json'), true);
if ($info) {
return $info['currentVersion'];
} else {
throw new Exception('The plugin has an invalid version file.');
}
}
public function getLabel()
{
return 'DsnFrontendBlocks';
}
public function install()
{
if (!$this->assertVersionGreaterThen('4.3.0')) {
throw new \RuntimeException('At least Shopware 4.3.0 is required');
}
$this->subscribeEvent(
'Enlight_Controller_Front_DispatchLoopStartup',
'onStartDispatch'
);
return true;
}
/**
* This callback function is triggered at the very beginning of the dispatch process and allows
* us to register additional events on the fly. This way you won't ever need to reinstall you
* plugin for new events - any event and hook can simply be registerend in the event subscribers
*/
public function onStartDispatch(Enlight_Event_EventArgs $args)
{
$this->registerMyComponents();
$subscribers = array(
new \Shopware\DsnFrontendBlocks\Subscriber\Frontend($this)
);
foreach ($subscribers as $subscriber) {
$this->Application()->Events()->addSubscriber($subscriber);
}
}
public function registerMyComponents()
{
$this->Application()->Loader()->registerNamespace(
'Shopware\DsnFrontendBlocks',
$this->Path()
);
}
}