|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Routes. |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Zikula contributors (Zikula) |
|
6
|
|
|
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
7
|
|
|
* @author Zikula contributors <[email protected]>. |
|
8
|
|
|
* @link http://www.zikula.org |
|
9
|
|
|
* @link http://zikula.org |
|
10
|
|
|
* @version Generated by ModuleStudio 0.7.5 (http://modulestudio.de). |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Zikula\RoutesModule\Base; |
|
14
|
|
|
|
|
15
|
|
|
use RuntimeException; |
|
16
|
|
|
use Zikula\Core\AbstractExtensionInstaller; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Installer base class. |
|
20
|
|
|
*/ |
|
21
|
|
|
abstract class AbstractRoutesModuleInstaller extends AbstractExtensionInstaller |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Install the ZikulaRoutesModule application. |
|
25
|
|
|
* |
|
26
|
|
|
* @return boolean True on success, or false |
|
27
|
|
|
* |
|
28
|
|
|
* @throws RuntimeException Thrown if database tables can not be created or another error occurs |
|
29
|
|
|
*/ |
|
30
|
|
|
public function install() |
|
31
|
|
|
{ |
|
32
|
|
|
$logger = $this->container->get('logger'); |
|
33
|
|
|
$userName = $this->container->get('zikula_users_module.current_user')->get('uname'); |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
// create all tables from according entity definitions |
|
36
|
|
|
try { |
|
37
|
|
|
$this->schemaTool->create($this->listEntityClasses()); |
|
38
|
|
|
} catch (\Exception $e) { |
|
39
|
|
|
$this->addFlash('error', $this->__('Doctrine Exception') . ': ' . $e->getMessage()); |
|
40
|
|
|
$logger->error('{app}: Could not create the database tables during installation. Error details: {errorMessage}.', ['app' => 'ZikulaRoutesModule', 'errorMessage' => $e->getMessage()]); |
|
41
|
|
|
|
|
42
|
|
|
return false; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
// set up all our vars with initial values |
|
46
|
|
|
$this->setVar('routeEntriesPerPage', '10'); |
|
47
|
|
|
|
|
48
|
|
|
// initialisation successful |
|
49
|
|
|
return true; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Upgrade the ZikulaRoutesModule application from an older version. |
|
54
|
|
|
* |
|
55
|
|
|
* If the upgrade fails at some point, it returns the last upgraded version. |
|
56
|
|
|
* |
|
57
|
|
|
* @param integer $oldVersion Version to upgrade from |
|
58
|
|
|
* |
|
59
|
|
|
* @return boolean True on success, false otherwise |
|
60
|
|
|
* |
|
61
|
|
|
* @throws RuntimeException Thrown if database tables can not be updated |
|
62
|
|
|
*/ |
|
63
|
|
|
public function upgrade($oldVersion) |
|
64
|
|
|
{ |
|
65
|
|
|
/* |
|
|
|
|
|
|
66
|
|
|
$logger = $this->container->get('logger'); |
|
67
|
|
|
|
|
68
|
|
|
// Upgrade dependent on old version number |
|
69
|
|
|
switch ($oldVersion) { |
|
70
|
|
|
case '1.0.0': |
|
71
|
|
|
// do something |
|
72
|
|
|
// ... |
|
73
|
|
|
// update the database schema |
|
74
|
|
|
try { |
|
75
|
|
|
$this->schemaTool->update($this->listEntityClasses()); |
|
76
|
|
|
} catch (\Exception $e) { |
|
77
|
|
|
$this->addFlash('error', $this->__('Doctrine Exception') . ': ' . $e->getMessage()); |
|
78
|
|
|
$logger->error('{app}: Could not update the database tables during the upgrade. Error details: {errorMessage}.', ['app' => 'ZikulaRoutesModule', 'errorMessage' => $e->getMessage()]); |
|
79
|
|
|
|
|
80
|
|
|
return false; |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
*/ |
|
84
|
|
|
|
|
85
|
|
|
// update successful |
|
86
|
|
|
return true; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Uninstall ZikulaRoutesModule. |
|
91
|
|
|
* |
|
92
|
|
|
* @return boolean True on success, false otherwise |
|
93
|
|
|
* |
|
94
|
|
|
* @throws RuntimeException Thrown if database tables or stored workflows can not be removed |
|
95
|
|
|
*/ |
|
96
|
|
|
public function uninstall() |
|
97
|
|
|
{ |
|
98
|
|
|
$logger = $this->container->get('logger'); |
|
99
|
|
|
|
|
100
|
|
|
try { |
|
101
|
|
|
$this->schemaTool->drop($this->listEntityClasses()); |
|
102
|
|
|
} catch (\Exception $e) { |
|
103
|
|
|
$this->addFlash('error', $this->__('Doctrine Exception') . ': ' . $e->getMessage()); |
|
104
|
|
|
$logger->error('{app}: Could not remove the database tables during uninstallation. Error details: {errorMessage}.', ['app' => 'ZikulaRoutesModule', 'errorMessage' => $e->getMessage()]); |
|
105
|
|
|
|
|
106
|
|
|
return false; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
// remove all module vars |
|
110
|
|
|
$this->delVars(); |
|
111
|
|
|
|
|
112
|
|
|
// uninstallation successful |
|
113
|
|
|
return true; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Build array with all entity classes for ZikulaRoutesModule. |
|
118
|
|
|
* |
|
119
|
|
|
* @return array list of class names |
|
120
|
|
|
*/ |
|
121
|
|
|
protected function listEntityClasses() |
|
122
|
|
|
{ |
|
123
|
|
|
$classNames = []; |
|
124
|
|
|
$classNames[] = 'Zikula\RoutesModule\Entity\RouteEntity'; |
|
125
|
|
|
|
|
126
|
|
|
return $classNames; |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.