|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Zikula package. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright Zikula - https://ziku.la/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Zikula\MailerModule; |
|
15
|
|
|
|
|
16
|
|
|
use Doctrine\Persistence\ManagerRegistry; |
|
17
|
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
|
18
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface; |
|
19
|
|
|
use Zikula\Bundle\CoreBundle\Doctrine\Helper\SchemaHelper; |
|
20
|
|
|
use Zikula\Bundle\CoreBundle\DynamicConfigDumper; |
|
21
|
|
|
use Zikula\ExtensionsModule\AbstractExtension; |
|
22
|
|
|
use Zikula\ExtensionsModule\Api\ApiInterface\VariableApiInterface; |
|
23
|
|
|
use Zikula\ExtensionsModule\Installer\AbstractExtensionInstaller; |
|
24
|
|
|
|
|
25
|
|
|
class MailerModuleInstaller extends AbstractExtensionInstaller |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @var DynamicConfigDumper |
|
29
|
|
|
*/ |
|
30
|
|
|
private $configDumper; |
|
31
|
|
|
|
|
32
|
|
|
public function __construct( |
|
33
|
|
|
DynamicConfigDumper $configDumper, |
|
34
|
|
|
AbstractExtension $extension, |
|
35
|
|
|
ManagerRegistry $managerRegistry, |
|
36
|
|
|
SchemaHelper $schemaTool, |
|
37
|
|
|
RequestStack $requestStack, |
|
38
|
|
|
TranslatorInterface $translator, |
|
39
|
|
|
VariableApiInterface $variableApi |
|
40
|
|
|
) { |
|
41
|
|
|
$this->configDumper = $configDumper; |
|
42
|
|
|
parent::__construct($extension, $managerRegistry, $schemaTool, $requestStack, $translator, $variableApi); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function install(): bool |
|
46
|
|
|
{ |
|
47
|
|
|
$this->setVars($this->getDefaults()); |
|
48
|
|
|
|
|
49
|
|
|
return true; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function upgrade(string $oldVersion): bool |
|
53
|
|
|
{ |
|
54
|
|
|
switch ($oldVersion) { |
|
55
|
|
|
case '1.5.0': // shipped with Core-1.4.3 |
|
56
|
|
|
case '1.5.1': // shipped with Core-2.0.15 |
|
57
|
|
|
// all swiftmailer config changes and module-vars removed from previous version upgrades above |
|
58
|
|
|
$this->configDumper->delConfiguration('swiftmailer'); |
|
59
|
|
|
$enableLogging = $this->getVar('enableLogging'); |
|
60
|
|
|
$this->delVars(); |
|
61
|
|
|
$this->setVar('enableLogging', $enableLogging); |
|
62
|
|
|
// future upgrade routines |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
return true; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function uninstall(): bool |
|
69
|
|
|
{ |
|
70
|
|
|
// Deletion not allowed |
|
71
|
|
|
return false; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Default module vars. |
|
76
|
|
|
*/ |
|
77
|
|
|
private function getDefaults(): array |
|
78
|
|
|
{ |
|
79
|
|
|
return [ |
|
80
|
|
|
'enableLogging' => false |
|
81
|
|
|
]; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|