-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeptacomAmp.php
51 lines (42 loc) · 1.38 KB
/
HeptacomAmp.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
<?php declare(strict_types=1);
namespace HeptacomAmp;
use Enlight_Controller_Request_Request;
use Enlight_Event_EventArgs;
use Shopware\Components\Plugin;
use Shopware\Components\Plugin\Context\ActivateContext;
use Shopware\Components\Plugin\Context\DeactivateContext;
use Shopware\Components\Plugin\Context\InstallContext;
use Shopware\Components\Plugin\Context\UpdateContext;
class HeptacomAmp extends Plugin
{
const PLUGIN_NAME = 'HeptacomAmp';
public function activate(ActivateContext $context)
{
$context->scheduleClearCache(InstallContext::CACHE_LIST_ALL);
}
public function deactivate(DeactivateContext $context)
{
$context->scheduleClearCache(InstallContext::CACHE_LIST_ALL);
}
public function update(UpdateContext $context)
{
$context->scheduleClearCache(InstallContext::CACHE_LIST_ALL);
}
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
'Enlight_Controller_Front_RouteShutdown' => 'autoloadComposer',
];
}
public function autoloadComposer(Enlight_Event_EventArgs $args)
{
/** @var Enlight_Controller_Request_Request $request */
$request = $args->get('request');
if ($request->getParam('amp', 0)) {
require_once implode(DIRECTORY_SEPARATOR, [$this->getPath(), 'vendor', 'autoload.php']);
}
}
}