-
Notifications
You must be signed in to change notification settings - Fork 3
/
SwagCookieConsentManager.php
60 lines (51 loc) · 2.03 KB
/
SwagCookieConsentManager.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
namespace SwagCookieConsentManager;
use Shopware\Components\Plugin;
use Shopware\Components\Plugin\Context\ActivateContext;
use Shopware\Components\Plugin\Context\InstallContext;
use Shopware\Components\Plugin\Context\UninstallContext;
use SwagCookieConsentManager\Bootstrap\Installer;
use SwagCookieConsentManager\Bootstrap\Uninstaller;
use Symfony\Component\ClassLoader\Psr4ClassLoader;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
$loader = new Psr4ClassLoader();
$loader->addPrefix('Shopware\Bundle\CookieBundle', __DIR__ . '/Bundle/CookieBundle/');
$loader->register();
class SwagCookieConsentManager extends Plugin
{
public function build(ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator($this->getPath() . '/Bundle/'));
$loader->load('CookieBundle/DependencyInjection/services.xml');
parent::build($container);
}
public function install(InstallContext $context)
{
$installer = new Installer($context, $this->container->get('dbal_connection'));
$installer->install();
}
public function activate(ActivateContext $context)
{
$context->scheduleClearCache([
InstallContext::CACHE_TAG_CONFIG,
InstallContext::CACHE_TAG_HTTP,
InstallContext::CACHE_TAG_TEMPLATE,
InstallContext::CACHE_TAG_THEME,
InstallContext::CACHE_TAG_PROXY
]);
}
public function uninstall(UninstallContext $context)
{
$uninstaller = new Uninstaller($context, $this->container->get('dbal_connection'), $context->assertMinimumVersion('5.6.3'));
$uninstaller->uninstall();
$context->scheduleClearCache([
InstallContext::CACHE_TAG_CONFIG,
InstallContext::CACHE_TAG_HTTP,
InstallContext::CACHE_TAG_TEMPLATE,
InstallContext::CACHE_TAG_THEME,
InstallContext::CACHE_TAG_PROXY
]);
}
}