1
1
<?php
2
+ /**
3
+ * @package moduleinternals
4
+ * @category OXID Module
5
+ * @version 1.0.1
6
+ * @license GPL3 License http://opensource.org/licenses/GPL
7
+ * @author Alfonsas Cirtautas / OXID Community
8
+ * @link https://github.com/OXIDprojects/ocb_cleartmp
9
+ * @see https://github.com/acirtautas/oxid-module-internals
10
+ */
2
11
3
- namespace OxCom \ModuleInternals \Core ;
12
+ namespace OxidCommunity \ModuleInternals \Core ;
4
13
5
14
use OxidEsales \Eshop \Core \DatabaseProvider ;
6
15
use OxidEsales \Eshop \Core \Module \Module ;
15
24
*/
16
25
class FixHelper
17
26
{
27
+
18
28
/** @var Module */
19
29
protected $ _oModule ;
20
30
@@ -33,8 +43,8 @@ class FixHelper
33
43
*/
34
44
public function __construct (Module $ oModule , ModuleList $ oModuleList , ModuleCache $ oModuleCache )
35
45
{
36
- $ this ->_oModule = $ oModule ;
37
- $ this ->_oModuleList = $ oModuleList ;
46
+ $ this ->_oModule = $ oModule ;
47
+ $ this ->_oModuleList = $ oModuleList ;
38
48
$ this ->_oModuleCache = $ oModuleCache ;
39
49
}
40
50
@@ -124,10 +134,10 @@ public function getInfo($sName, $iLang = null)
124
134
*/
125
135
public function fixVersion ()
126
136
{
127
- $ sVersion = $ this ->getInfo ('version ' );
128
- $ aVersions = (array )Registry::getConfig ()->getConfigParam ('aModuleVersions ' );
137
+ $ sVersion = $ this ->getInfo ('version ' );
138
+ $ aVersions = (array ) Registry::getConfig ()->getConfigParam ('aModuleVersions ' );
129
139
if (is_array ($ aVersions )) {
130
- $ aVersions [$ this ->getModuleId ()] = $ sVersion ;
140
+ $ aVersions [ $ this ->getModuleId () ] = $ sVersion ;
131
141
}
132
142
133
143
$ this ->_saveToConfig ('aModuleVersions ' , $ aVersions );
@@ -140,7 +150,7 @@ public function fixVersion()
140
150
public function fixExtend ()
141
151
{
142
152
$ aExtendedClassesOfModule = $ this ->getInfo ('extend ' );
143
- $ aInstalledModules = Registry::getConfig ()->getModulesWithExtendedClass ();
153
+ $ aInstalledModules = Registry::getConfig ()->getModulesWithExtendedClass ();
144
154
145
155
$ sModulePath = $ this ->getModulePath ();
146
156
@@ -149,7 +159,7 @@ public function fixExtend()
149
159
$ aModules = $ this ->removeExtendedClassesOfModule ($ aInstalledModules , $ sModulePath );
150
160
}
151
161
152
- $ aModules = $ this ->_mergeModuleArrays ($ aInstalledModules , $ aExtendedClassesOfModule );
162
+ $ aModules = $ this ->_mergeModuleArrays ($ aInstalledModules , $ aExtendedClassesOfModule );
153
163
$ aModuleChains = $ this ->getModuleList ()->buildModuleChains ($ aModules );
154
164
155
165
$ this ->_saveToConfig ('aModules ' , $ aModuleChains );
@@ -162,10 +172,10 @@ public function fixExtend()
162
172
public function fixFiles ()
163
173
{
164
174
$ aModuleFiles = $ this ->getInfo ('files ' );
165
- $ aFiles = (array )Registry::getConfig ()->getConfigParam ('aModuleFiles ' );
175
+ $ aFiles = (array ) Registry::getConfig ()->getConfigParam ('aModuleFiles ' );
166
176
167
177
if (is_array ($ aModuleFiles )) {
168
- $ aFiles [$ this ->getModuleId ()] = array_change_key_case ($ aModuleFiles , CASE_LOWER );
178
+ $ aFiles [ $ this ->getModuleId () ] = array_change_key_case ($ aModuleFiles , CASE_LOWER );
169
179
}
170
180
171
181
$ this ->_saveToConfig ('aModuleFiles ' , $ aFiles );
@@ -179,9 +189,9 @@ public function fixTemplates()
179
189
{
180
190
$ aModuleTemplates = $ this ->getInfo ('templates ' );
181
191
182
- $ aTemplates = (array )Registry::getConfig ()->getConfigParam ('aModuleTemplates ' );
192
+ $ aTemplates = (array ) Registry::getConfig ()->getConfigParam ('aModuleTemplates ' );
183
193
if (is_array ($ aModuleTemplates )) {
184
- $ aTemplates [$ this ->getModuleId ()] = $ aModuleTemplates ;
194
+ $ aTemplates [ $ this ->getModuleId () ] = $ aModuleTemplates ;
185
195
}
186
196
187
197
$ this ->_saveToConfig ('aModuleTemplates ' , $ aTemplates );
@@ -193,15 +203,15 @@ public function fixTemplates()
193
203
*/
194
204
public function fixBlocks ()
195
205
{
196
- $ oConfig = Registry::getConfig ();
206
+ $ oConfig = Registry::getConfig ();
197
207
$ aModuleBlocks = $ this ->getInfo ('blocks ' );
198
- $ sShopId = $ oConfig ->getShopId ();
199
- $ oDb = DatabaseProvider::getDb ();
208
+ $ sShopId = $ oConfig ->getShopId ();
209
+ $ oDb = DatabaseProvider::getDb ();
200
210
201
211
// Cleanup !!!
202
212
$ oDb ->execute (
203
213
'DELETE FROM oxtplblocks WHERE oxmodule = ? AND oxshopid = ? ' ,
204
- array ( $ this ->getModuleId (), $ sShopId)
214
+ [ $ this ->getModuleId (), $ sShopId]
205
215
);
206
216
207
217
if (is_array ($ aModuleBlocks )) {
@@ -213,15 +223,15 @@ public function fixBlocks()
213
223
' ;
214
224
215
225
foreach ($ aModuleBlocks as $ aValue ) {
216
- $ sOxId = Registry::get ('oxUtilsObject ' )->generateUId ();
226
+ $ sOxId = Registry::get ('oxUtilsObject ' )->generateUId ();
217
227
$ sTemplate = $ aValue ['template ' ];
218
228
$ iPosition = $ aValue ['position ' ] ? $ aValue ['position ' ] : 1 ;
219
- $ sBlock = $ aValue ['block ' ];
220
- $ sFile = $ aValue ['file ' ];
229
+ $ sBlock = $ aValue ['block ' ];
230
+ $ sFile = $ aValue ['file ' ];
221
231
222
232
$ oDb ->execute (
223
233
$ sSql ,
224
- array ( $ sOxId , 1 , $ sShopId , $ sTemplate , $ sBlock , $ iPosition , $ sFile , $ this ->getModuleId ())
234
+ [ $ sOxId , 1 , $ sShopId , $ sTemplate , $ sBlock , $ iPosition , $ sFile , $ this ->getModuleId ()]
225
235
);
226
236
}
227
237
}
@@ -235,29 +245,29 @@ public function fixBlocks()
235
245
public function fixSettings ()
236
246
{
237
247
$ aModuleSettings = $ this ->getInfo ('settings ' );
238
- $ oConfig = Registry::getConfig ();
239
- $ sShopId = $ oConfig ->getShopId ();
240
- $ oDb = DatabaseProvider::getDb ();
248
+ $ oConfig = Registry::getConfig ();
249
+ $ sShopId = $ oConfig ->getShopId ();
250
+ $ oDb = DatabaseProvider::getDb ();
241
251
242
252
// Cleanup !!!
243
253
$ oDb ->execute (
244
254
'DELETE FROM oxconfig WHERE oxmodule = ? AND oxshopid = ? ' ,
245
- array ( sprintf ('module:%s ' , $ this ->getModuleId ()), $ sShopId)
255
+ [ sprintf ('module:%s ' , $ this ->getModuleId ()), $ sShopId]
246
256
);
247
- $ oDb ->execute ('DELETE FROM oxconfigdisplay WHERE oxcfgmodule = ? ' , array ( $ this ->getModuleId ()) );
257
+ $ oDb ->execute ('DELETE FROM oxconfigdisplay WHERE oxcfgmodule = ? ' , [ $ this ->getModuleId ()] );
248
258
249
259
if (is_array ($ aModuleSettings )) {
250
260
251
261
foreach ($ aModuleSettings as $ aValue ) {
252
262
$ sOxId = Registry::get ('oxUtilsObject ' )->generateUId ();
253
263
254
264
$ sModule = 'module: ' . $ this ->getModuleId ();
255
- $ sName = $ aValue ['name ' ];
256
- $ sType = $ aValue ['type ' ];
257
- $ sValue = is_null ($ oConfig ->getConfigParam ($ sName )) ? $ aValue ['value ' ] : $ oConfig ->getConfigParam (
265
+ $ sName = $ aValue ['name ' ];
266
+ $ sType = $ aValue ['type ' ];
267
+ $ sValue = is_null ($ oConfig ->getConfigParam ($ sName )) ? $ aValue ['value ' ] : $ oConfig ->getConfigParam (
258
268
$ sName
259
269
);
260
- $ sGroup = $ aValue ['group ' ];
270
+ $ sGroup = $ aValue ['group ' ];
261
271
262
272
$ sConstraints = '' ;
263
273
if ($ aValue ['constraints ' ]) {
@@ -278,7 +288,7 @@ public function fixSettings()
278
288
(?, ?, ?, ?, ?, ?)
279
289
' ;
280
290
281
- $ oDb ->execute ($ sInsertSql , array ( $ sOxId , $ sModule , $ sName , $ sGroup , $ sConstraints , $ iPosition) );
291
+ $ oDb ->execute ($ sInsertSql , [ $ sOxId , $ sModule , $ sName , $ sGroup , $ sConstraints , $ iPosition] );
282
292
}
283
293
}
284
294
@@ -291,10 +301,10 @@ public function fixSettings()
291
301
public function fixEvents ()
292
302
{
293
303
$ aModuleEvents = $ this ->getInfo ('events ' );
294
- $ aEvents = (array )Registry::getConfig ()->getConfigParam ('aModuleEvents ' );
304
+ $ aEvents = (array ) Registry::getConfig ()->getConfigParam ('aModuleEvents ' );
295
305
296
306
if (is_array ($ aEvents )) {
297
- $ aEvents [$ this ->getModuleId ()] = $ aModuleEvents ;
307
+ $ aEvents [ $ this ->getModuleId () ] = $ aModuleEvents ;
298
308
}
299
309
300
310
$ this ->_saveToConfig ('aModuleEvents ' , $ aEvents );
@@ -323,16 +333,16 @@ protected function _mergeModuleArrays($aAllModuleArray, $aAddModuleArray)
323
333
if (is_array ($ aAllModuleArray ) && is_array ($ aAddModuleArray )) {
324
334
foreach ($ aAddModuleArray as $ sClass => $ aModuleChain ) {
325
335
if (!is_array ($ aModuleChain )) {
326
- $ aModuleChain = array ( $ aModuleChain) ;
336
+ $ aModuleChain = [ $ aModuleChain] ;
327
337
}
328
- if (isset ($ aAllModuleArray [$ sClass ])) {
338
+ if (isset ($ aAllModuleArray [ $ sClass ])) {
329
339
foreach ($ aModuleChain as $ sModule ) {
330
- if (!in_array ($ sModule , $ aAllModuleArray [$ sClass ])) {
331
- $ aAllModuleArray [$ sClass ][] = $ sModule ;
340
+ if (!in_array ($ sModule , $ aAllModuleArray [ $ sClass ])) {
341
+ $ aAllModuleArray [ $ sClass ][] = $ sModule ;
332
342
}
333
343
}
334
344
} else {
335
- $ aAllModuleArray [$ sClass ] = $ aModuleChain ;
345
+ $ aAllModuleArray [ $ sClass ] = $ aModuleChain ;
336
346
}
337
347
}
338
348
}
@@ -368,11 +378,11 @@ protected function removeExtendedClassesOfModule($aInstalledModules, $sModulePat
368
378
if ($ this ->getModule ()->checkMetaDataVersion ('2.0 ' )) {
369
379
$ moduleNameSpace = $ this ->getModule ()->getModuleNameSpace ($ sModulePath );
370
380
if (strpos ($ sModuleClassName , $ moduleNameSpace ) !== false ) {
371
- unset($ aInstalledModules [$ shopClassName][ $ sKey ]);
381
+ unset($ aInstalledModules [ $ shopClassName ][ $ sKey ]);
372
382
}
373
383
} else {
374
384
if (strpos ($ sModuleClassName , $ sModulePath . '/ ' ) === 0 ) {
375
- unset($ aInstalledModules [$ shopClassName][ $ sKey ]);
385
+ unset($ aInstalledModules [ $ shopClassName ][ $ sKey ]);
376
386
}
377
387
}
378
388
}
0 commit comments