1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BFW\Install; |
4
|
|
|
|
5
|
|
|
use \BFW\Helpers\Cli; |
6
|
|
|
use \BFW\Install\ModuleInstall; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Application class for install module script |
10
|
|
|
*/ |
11
|
|
|
class Application extends \BFW\Application |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var \BFW\Install\ModuleInstall[] $modulesInstall Modules to install |
15
|
|
|
*/ |
16
|
|
|
protected static $modulesInstall = []; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Getter to static property modulesInstall |
20
|
|
|
* |
21
|
|
|
* @return \BFW\Install\ModuleInstall[] |
22
|
|
|
*/ |
23
|
|
|
public static function getModulesInstall() |
24
|
|
|
{ |
25
|
|
|
return self::$modulesInstall; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* {@inheritdoc} |
30
|
|
|
*/ |
31
|
|
|
protected function initRequest() |
32
|
|
|
{ |
33
|
|
|
return; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritdoc} |
38
|
|
|
*/ |
39
|
|
|
protected function initSession() |
40
|
|
|
{ |
41
|
|
|
return; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritdoc} |
46
|
|
|
*/ |
47
|
|
|
protected function initErrors() |
48
|
|
|
{ |
49
|
|
|
return; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritdoc} |
54
|
|
|
*/ |
55
|
|
|
protected function initCli() |
56
|
|
|
{ |
57
|
|
|
return; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Add a new module in the list to install |
62
|
|
|
* |
63
|
|
|
* @param \BFW\Install\ModuleInstall $module |
64
|
|
|
* |
65
|
|
|
* @return void |
66
|
|
|
*/ |
67
|
|
|
public static function addModuleInstall(ModuleInstall $module) |
68
|
|
|
{ |
69
|
|
|
$moduleName = $module->getName(); |
70
|
|
|
|
71
|
|
|
self::$modulesInstall[$moduleName] = $module; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* {@inheritdoc} |
76
|
|
|
*/ |
77
|
|
|
protected function declareRunSteps() |
78
|
|
|
{ |
79
|
|
|
$this->runSteps = [ |
80
|
|
|
[$this, 'loadMemcached'], |
81
|
|
|
[$this, 'loadAllModules'], |
82
|
|
|
[$this, 'installAllModules'] |
83
|
|
|
]; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* {@inheritdoc} |
88
|
|
|
*/ |
89
|
|
|
public function run() |
90
|
|
|
{ |
91
|
|
|
$runTasks = $this->getSubjectForName('ApplicationTasks'); |
92
|
|
|
|
93
|
|
|
$runTasks->setNotifyPrefix('BfwAppModulesInstall'); |
|
|
|
|
94
|
|
|
$runTasks->run(); |
95
|
|
|
$runTasks->sendNotify('bfw_modules_install_done'); |
|
|
|
|
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Install all modules in the order of the dependency tree. |
100
|
|
|
* |
101
|
|
|
* @return void |
102
|
|
|
*/ |
103
|
|
|
protected function installAllModules() |
104
|
|
|
{ |
105
|
|
|
Cli::displayMsgNL('Read all modules to run install script...'); |
106
|
|
|
|
107
|
|
|
$tree = $this->modules->getLoadTree(); |
108
|
|
|
|
109
|
|
|
foreach ($tree as $firstLine) { |
110
|
|
|
foreach ($firstLine as $secondLine) { |
111
|
|
|
foreach ($secondLine as $moduleName) { |
112
|
|
|
if (!isset(self::$modulesInstall[$moduleName])) { |
113
|
|
|
continue; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
$this->installModule($moduleName); |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
Cli::displayMsgNL('All modules have been read.'); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Install a module |
126
|
|
|
* |
127
|
|
|
* @param string $moduleName The module name |
128
|
|
|
* |
129
|
|
|
* @return void |
130
|
|
|
*/ |
131
|
|
|
protected function installModule($moduleName) |
132
|
|
|
{ |
133
|
|
|
if (!isset(self::$modulesInstall[$moduleName])) { |
134
|
|
|
return; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
Cli::displayMsgNL(' > Read for module '.$moduleName); |
138
|
|
|
|
139
|
|
|
$module = self::$modulesInstall[$moduleName]; |
140
|
|
|
$installScripts = $module->getSourceInstallScript(); |
141
|
|
|
|
142
|
|
|
if ($installScripts === '') { |
143
|
|
|
Cli::displayMsgNL(' >> No script to run.'); |
144
|
|
|
return; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
if (is_string($installScripts)) { |
148
|
|
|
$installScripts = (array) $installScripts; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
foreach ($installScripts as $scriptPath) { |
|
|
|
|
152
|
|
|
$module->runInstallScript($scriptPath); |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.