-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontroller.php
More file actions
88 lines (71 loc) · 1.95 KB
/
Copy pathcontroller.php
File metadata and controls
88 lines (71 loc) · 1.95 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
<?php
namespace Concrete\Package\ActiveCookieConsentThirdParty;
use Concrete\Core\Block\BlockType\BlockType;
use Concrete\Core\Database\EntityManager\Provider\ProviderInterface;
use Concrete\Core\Package\Package;
use Concrete\Package\ActiveCookieConsentThirdParty\Module\Module;
class Controller extends Package implements ProviderInterface
{
protected $pkgHandle = 'active_cookie_consent_third_party';
protected $appVersionRequired = '8.5.1';
protected $pkgVersion = '1.4.0';
protected $packageDependencies = ['active_cookie_consent' => '1.3.0'];
public function getPackageDescription(): string
{
return t('Add Support for ThirdParty Cookie Control');
}
public function getPackageName(): string
{
return t('Third Party Cookie Consent');
}
public function on_start()
{
Module::boot();
}
public function install()
{
$pkg = parent::install();
$config = $this->getConfig();
$config->save('youtube.enabled', 1);
$config->save('gmap.enabled', 1);
return $pkg;
}
public function upgrade()
{
parent::upgrade();
$this->restoreOverriddenBlocks();
}
public function uninstall()
{
$this->restoreOverriddenBlocks();
parent::uninstall();
}
/**
* {@inheritdoc}
*/
public function getPackageAutoloaderRegistries(): array
{
if (!class_exists(Module::class)) {
return ['src' => 'Concrete\Package\ActiveCookieConsentThirdParty'];
}
return [];
}
/**
* {@inheritdoc}
*/
public function getDrivers(): array
{
return [];
}
/**
* Restore Overridden Blocks.
*/
private function restoreOverriddenBlocks(): void
{
foreach (['youtube', 'google_map'] as $btHandle) {
$bt = BlockType::getByHandle($btHandle);
$bt->setPackageID(0);
$bt->refresh();
}
}
}