|
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\SearchModule; |
|
15
|
|
|
|
|
16
|
|
|
use Zikula\ExtensionsModule\Installer\AbstractExtensionInstaller; |
|
17
|
|
|
use Zikula\SearchModule\Entity\SearchResultEntity; |
|
18
|
|
|
use Zikula\SearchModule\Entity\SearchStatEntity; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Installation routines for the search module. |
|
22
|
|
|
*/ |
|
23
|
|
|
class SearchModuleInstaller extends AbstractExtensionInstaller |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var array |
|
27
|
|
|
*/ |
|
28
|
|
|
private $entities = [ |
|
29
|
|
|
SearchResultEntity::class, |
|
30
|
|
|
SearchStatEntity::class |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
public function install(): bool |
|
34
|
|
|
{ |
|
35
|
|
|
// create schema |
|
36
|
|
|
$this->schemaTool->create($this->entities); |
|
37
|
|
|
|
|
38
|
|
|
// create module vars |
|
39
|
|
|
$this->setVar('itemsperpage', 10); |
|
40
|
|
|
$this->setVar('limitsummary', 255); |
|
41
|
|
|
$this->setVar('opensearch_enabled', true); |
|
42
|
|
|
$this->setVar('opensearch_adult_content', false); |
|
43
|
|
|
|
|
44
|
|
|
// Initialisation successful |
|
45
|
|
|
return true; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function upgrade(string $oldVersion): bool |
|
49
|
|
|
{ |
|
50
|
|
|
// Upgrade dependent on old version number |
|
51
|
|
|
switch ($oldVersion) { |
|
52
|
|
|
case '1.5.2': |
|
53
|
|
|
$this->setVar('opensearch_enabled', true); |
|
54
|
|
|
$this->setVar('opensearch_adult_content', false); |
|
55
|
|
|
|
|
56
|
|
|
// update schema |
|
57
|
|
|
$this->schemaTool->update([ |
|
58
|
|
|
SearchResultEntity::class |
|
59
|
|
|
]); |
|
60
|
|
|
case '1.5.3': |
|
61
|
|
|
// update schema |
|
62
|
|
|
$this->schemaTool->update([ |
|
63
|
|
|
SearchResultEntity::class |
|
64
|
|
|
]); |
|
65
|
|
|
case '1.5.4': |
|
66
|
|
|
// nothing |
|
67
|
|
|
case '1.6.0': |
|
68
|
|
|
// update schema since extra field has been changed from text to array |
|
69
|
|
|
$this->entityManager->getRepository('ZikulaSearchModule:SearchResultEntity')->truncateTable(); |
|
|
|
|
|
|
70
|
|
|
$this->schemaTool->update([ |
|
71
|
|
|
SearchResultEntity::class |
|
72
|
|
|
]); |
|
73
|
|
|
case '1.6.1': |
|
74
|
|
|
// future upgrade routines |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
// Update successful |
|
78
|
|
|
return true; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function uninstall(): bool |
|
82
|
|
|
{ |
|
83
|
|
|
$this->schemaTool->drop($this->entities); |
|
84
|
|
|
|
|
85
|
|
|
// Delete any module variables |
|
86
|
|
|
$this->delVars(); |
|
87
|
|
|
|
|
88
|
|
|
// Deletion successful |
|
89
|
|
|
return true; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|