-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontroller.php
141 lines (119 loc) · 5.86 KB
/
controller.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
namespace Concrete\Package\Gdpr;
use A3020\Gdpr\DataTransfer\Task\ProcessDataTransferRequestsController;
use A3020\Gdpr\Form\Task\DeleteExpressFormEntriesController;
use A3020\Gdpr\Form\Task\DeleteLegacyFormEntriesController;
use A3020\Gdpr\Help\HelpServiceProvider;
use A3020\Gdpr\Installer\Installer;
use A3020\Gdpr\Installer\TaskInstaller;
use A3020\Gdpr\Installer\Uninstaller;
use A3020\Gdpr\Job\JobInstallService;
use Concrete\Core\Command\Task\Manager as TaskManager;
use Concrete\Core\Config\Repository\Repository;
use Concrete\Core\Package\Package;
use Concrete\Core\Support\Facade\Package as PackageFacade;
use Gettext\Translations;
final class Controller extends Package
{
protected $pkgHandle = 'gdpr';
protected $appVersionRequired = '8.4.4';
protected $pkgVersion = '1.9.0';
protected $pkgAutoloaderRegistries = [
'src/Gdpr' => '\A3020\Gdpr',
];
public function getPackageName()
{
return t('GDPR');
}
public function getPackageDescription()
{
return t('Helps you to comply with the GDPR regulation.');
}
public function on_start()
{
$app = $this->app;
/** @var @var \A3020\Gdpr\Provider\GdprServiceProvider $provider */
$provider = $app->make(\A3020\Gdpr\Provider\GdprServiceProvider::class);
$provider->register();
/** @var @var \A3020\Gdpr\Provider\CookieServiceProvider $provider */
$provider = $app->make(\A3020\Gdpr\Provider\CookieServiceProvider::class);
$provider->register();
/** @var HelpServiceProvider $helpServiceProvider */
$helpServiceProvider = $app->make(HelpServiceProvider::class);
$helpServiceProvider->register();
/** @var TaskManager $taskManager */
$taskManager = $app->make(TaskManager::class);
/** @var TaskInstaller $taskInstaller */
$taskInstaller = $app->make(TaskInstaller::class, ['package' => $this->getPackageEntity()]);
if ($taskInstaller->isInstalled('gdpr_process_data_transfer_requests')) {
$taskManager->extend('gdpr_process_data_transfer_requests', static function() use ($app) {
return $app->make(ProcessDataTransferRequestsController::class);
});
}
if ($taskInstaller->isInstalled('gdpr_remove_form_submissions')) {
$taskManager->extend('gdpr_remove_form_submissions', static function() use ($app) {
return $app->make(DeleteExpressFormEntriesController::class);
});
}
if ($taskInstaller->isInstalled('gdpr_remove_legacy_form_submissions')) {
$taskManager->extend('gdpr_remove_legacy_form_submissions', static function() use ($app) {
return $app->make(DeleteLegacyFormEntriesController::class);
});
}
}
public function install()
{
$pkg = parent::install();
$installer = $this->app->make(Installer::class);
$installer->install($pkg);
}
public function upgrade()
{
parent::upgrade();
/** @see \Concrete\Core\Package\PackageService */
$pkg = PackageFacade::getByHandle($this->pkgHandle);
$installer = $this->app->make(Installer::class);
$installer->install($pkg);
if (class_exists(TaskManager::class)) {
/** @var JobInstallService $jobInstaller */
$jobInstaller = $this->app->make(JobInstallService::class);
/** @var TaskInstaller $taskInstaller */
$taskInstaller = $this->app->make(TaskInstaller::class, ['package' => $this->getPackageEntity()]);
if ($jobInstaller->isInstalled('gdpr_process_data_transfer_requests')) {
$jobInstaller->installOrDeinstall('gdpr_process_data_transfer_requests', false);
$taskInstaller->install('gdpr_process_data_transfer_requests');
}
if ($jobInstaller->isInstalled('gdpr_remove_form_submissions')) {
$jobInstaller->installOrDeinstall('gdpr_remove_form_submissions', false);
$taskInstaller->install('gdpr_remove_form_submissions');
}
if ($jobInstaller->isInstalled('gdpr_remove_legacy_form_submissions')) {
$jobInstaller->installOrDeinstall('gdpr_remove_legacy_form_submissions', false);
$taskInstaller->install('gdpr_remove_legacy_form_submissions');
}
}
}
public function uninstall()
{
/** @see \Concrete\Core\Package\PackageService */
$pkg = PackageFacade::getByHandle($this->pkgHandle);
$uninstaller = $this->app->make(Uninstaller::class);
$uninstaller->uninstall($pkg);
parent::uninstall();
}
public function getTranslatableStrings(Translations $translations)
{
$config = $this->app->make(Repository::class);
// See also src/Gdpr/Cookie/Configuration.php
$message = $config->get('gdpr.cookies.consent.message');
$dismissButtonText = $config->get('gdpr.cookies.consent.dismiss_button_text');
$allowButtonText = $config->get('gdpr.cookies.consent.allow_button_text');
$denyButtonText = $config->get('gdpr.cookies.consent.deny_button_text');
$policyLinkText = $config->get('gdpr.cookies.consent.policy_link_text');
$translations->insert('CookieBar', $message ? $message : 'This website uses cookies to ensure you get the best experience on our website.');
$translations->insert('CookieBar', $dismissButtonText ? $dismissButtonText : 'Got it!');
$translations->insert('CookieBar', $allowButtonText ? $allowButtonText : 'Allow cookies');
$translations->insert('CookieBar', $denyButtonText ? $denyButtonText : 'Decline');
$translations->insert('CookieBar', $policyLinkText ? $policyLinkText :'Learn more');
}
}