Skip to content

Commit 912e069

Browse files
committed
2017-12-15 1.0.1 namespace, docblocks
1 parent 89db1b2 commit 912e069

19 files changed

+391
-265
lines changed

Controller/Admin/Metadata.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<?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+
*/
211

3-
namespace OxCom\ModuleInternals\Controller\Admin;
12+
namespace OxidCommunity\ModuleInternals\Controller\Admin;
413

514
use OxidEsales\Eshop\Application\Controller\Admin\AdminController;
615
use OxidEsales\Eshop\Core\Module\Module as Module;
@@ -16,6 +25,7 @@
1625
*/
1726
class Metadata extends AdminController
1827
{
28+
1929
/**
2030
* @var string
2131
*/

Controller/Admin/ModuleList.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<?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+
*/
211

3-
namespace OxCom\ModuleInternals\Controller\Admin;
12+
namespace OxidCommunity\ModuleInternals\Controller\Admin;
413

514
/**
615
* Class Metadata

Controller/Admin/State.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
<?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+
*/
211

3-
namespace OxCom\ModuleInternals\Controller\Admin;
12+
namespace OxidCommunity\ModuleInternals\Controller\Admin;
413

5-
use OxCom\ModuleInternals\Core\FixHelper as FixHelper;
14+
use OxidCommunity\ModuleInternals\Core\FixHelper as FixHelper;
615
use OxidEsales\Eshop\Application\Controller\Admin\AdminController;
716
use OxidEsales\Eshop\Core\Module\ModuleCache as ModuleCache;
817
use OxidEsales\Eshop\Core\Module\ModuleList as ModuleList;
@@ -19,6 +28,7 @@
1928
*/
2029
class State extends AdminController
2130
{
31+
2232
/**
2333
* @var string
2434
*/
@@ -47,7 +57,7 @@ public function __construct()
4757
*/
4858
public function getModuleFixHelper()
4959
{
50-
if ($this->_oModuleFixHelper === NULL) {
60+
if ($this->_oModuleFixHelper === null) {
5161
$this->_oModuleFixHelper = oxNew(
5262
FixHelper::class,
5363
$this->getModule(),
@@ -74,7 +84,7 @@ public function setModuleFixHelper($oModuleFixHelper)
7484
*/
7585
public function getModule()
7686
{
77-
if ($this->_oModule === NULL) {
87+
if ($this->_oModule === null) {
7888
$sModuleId = $this->getEditObjectId();
7989

8090
$this->addTplParam('oxid', $sModuleId);

Controller/Admin/Utils.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<?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+
*/
211

3-
namespace OxCom\ModuleInternals\Controller\Admin;
12+
namespace OxidCommunity\ModuleInternals\Controller\Admin;
413

514
use \OxidEsales\Eshop\Core\Module\Module as Module;
615
use \OxidEsales\Eshop\Core\Module\ModuleCache as ModuleCache;
@@ -17,6 +26,7 @@
1726
*/
1827
class Utils extends \OxidEsales\Eshop\Application\Controller\Admin\AdminController
1928
{
29+
2030
/** @var oxModule */
2131
protected $_oModule;
2232

@@ -38,7 +48,7 @@ class Utils extends \OxidEsales\Eshop\Application\Controller\Admin\AdminControll
3848
*/
3949
public function getModule()
4050
{
41-
if ($this->_oModule === NULL) {
51+
if ($this->_oModule === null) {
4252
$sModuleId = $this->getEditObjectId();
4353

4454
$this->addTplParam('oxid', $sModuleId);
@@ -56,7 +66,7 @@ public function getModule()
5666
*/
5767
public function getModuleCache()
5868
{
59-
if ($this->_oModuleCache === NULL) {
69+
if ($this->_oModuleCache === null) {
6070
$this->_oModuleCache = oxNew(ModuleCache::class, $this->getModule());
6171
}
6272

@@ -70,7 +80,7 @@ public function getModuleCache()
7080
*/
7181
public function getModuleInstaller()
7282
{
73-
if ($this->_oModuleInstaller === NULL) {
83+
if ($this->_oModuleInstaller === null) {
7484
$this->_oModuleInstaller = oxNew(ModuleInstaller::class, $this->getModuleCache());
7585
}
7686

Core/FixHelper.php

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<?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+
*/
211

3-
namespace OxCom\ModuleInternals\Core;
12+
namespace OxidCommunity\ModuleInternals\Core;
413

514
use OxidEsales\Eshop\Core\DatabaseProvider;
615
use OxidEsales\Eshop\Core\Module\Module;
@@ -15,6 +24,7 @@
1524
*/
1625
class FixHelper
1726
{
27+
1828
/** @var Module */
1929
protected $_oModule;
2030

@@ -33,8 +43,8 @@ class FixHelper
3343
*/
3444
public function __construct(Module $oModule, ModuleList $oModuleList, ModuleCache $oModuleCache)
3545
{
36-
$this->_oModule = $oModule;
37-
$this->_oModuleList = $oModuleList;
46+
$this->_oModule = $oModule;
47+
$this->_oModuleList = $oModuleList;
3848
$this->_oModuleCache = $oModuleCache;
3949
}
4050

@@ -124,10 +134,10 @@ public function getInfo($sName, $iLang = null)
124134
*/
125135
public function fixVersion()
126136
{
127-
$sVersion = $this->getInfo('version');
128-
$aVersions = (array)Registry::getConfig()->getConfigParam('aModuleVersions');
137+
$sVersion = $this->getInfo('version');
138+
$aVersions = (array) Registry::getConfig()->getConfigParam('aModuleVersions');
129139
if (is_array($aVersions)) {
130-
$aVersions[$this->getModuleId()] = $sVersion;
140+
$aVersions[ $this->getModuleId() ] = $sVersion;
131141
}
132142

133143
$this->_saveToConfig('aModuleVersions', $aVersions);
@@ -140,7 +150,7 @@ public function fixVersion()
140150
public function fixExtend()
141151
{
142152
$aExtendedClassesOfModule = $this->getInfo('extend');
143-
$aInstalledModules = Registry::getConfig()->getModulesWithExtendedClass();
153+
$aInstalledModules = Registry::getConfig()->getModulesWithExtendedClass();
144154

145155
$sModulePath = $this->getModulePath();
146156

@@ -149,7 +159,7 @@ public function fixExtend()
149159
$aModules = $this->removeExtendedClassesOfModule($aInstalledModules, $sModulePath);
150160
}
151161

152-
$aModules = $this->_mergeModuleArrays($aInstalledModules, $aExtendedClassesOfModule);
162+
$aModules = $this->_mergeModuleArrays($aInstalledModules, $aExtendedClassesOfModule);
153163
$aModuleChains = $this->getModuleList()->buildModuleChains($aModules);
154164

155165
$this->_saveToConfig('aModules', $aModuleChains);
@@ -162,10 +172,10 @@ public function fixExtend()
162172
public function fixFiles()
163173
{
164174
$aModuleFiles = $this->getInfo('files');
165-
$aFiles = (array)Registry::getConfig()->getConfigParam('aModuleFiles');
175+
$aFiles = (array) Registry::getConfig()->getConfigParam('aModuleFiles');
166176

167177
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);
169179
}
170180

171181
$this->_saveToConfig('aModuleFiles', $aFiles);
@@ -179,9 +189,9 @@ public function fixTemplates()
179189
{
180190
$aModuleTemplates = $this->getInfo('templates');
181191

182-
$aTemplates = (array)Registry::getConfig()->getConfigParam('aModuleTemplates');
192+
$aTemplates = (array) Registry::getConfig()->getConfigParam('aModuleTemplates');
183193
if (is_array($aModuleTemplates)) {
184-
$aTemplates[$this->getModuleId()] = $aModuleTemplates;
194+
$aTemplates[ $this->getModuleId() ] = $aModuleTemplates;
185195
}
186196

187197
$this->_saveToConfig('aModuleTemplates', $aTemplates);
@@ -193,15 +203,15 @@ public function fixTemplates()
193203
*/
194204
public function fixBlocks()
195205
{
196-
$oConfig = Registry::getConfig();
206+
$oConfig = Registry::getConfig();
197207
$aModuleBlocks = $this->getInfo('blocks');
198-
$sShopId = $oConfig->getShopId();
199-
$oDb = DatabaseProvider::getDb();
208+
$sShopId = $oConfig->getShopId();
209+
$oDb = DatabaseProvider::getDb();
200210

201211
// Cleanup !!!
202212
$oDb->execute(
203213
'DELETE FROM oxtplblocks WHERE oxmodule = ? AND oxshopid = ?',
204-
array($this->getModuleId(), $sShopId)
214+
[$this->getModuleId(), $sShopId]
205215
);
206216

207217
if (is_array($aModuleBlocks)) {
@@ -213,15 +223,15 @@ public function fixBlocks()
213223
';
214224

215225
foreach ($aModuleBlocks as $aValue) {
216-
$sOxId = Registry::get('oxUtilsObject')->generateUId();
226+
$sOxId = Registry::get('oxUtilsObject')->generateUId();
217227
$sTemplate = $aValue['template'];
218228
$iPosition = $aValue['position'] ? $aValue['position'] : 1;
219-
$sBlock = $aValue['block'];
220-
$sFile = $aValue['file'];
229+
$sBlock = $aValue['block'];
230+
$sFile = $aValue['file'];
221231

222232
$oDb->execute(
223233
$sSql,
224-
array($sOxId, 1, $sShopId, $sTemplate, $sBlock, $iPosition, $sFile, $this->getModuleId())
234+
[$sOxId, 1, $sShopId, $sTemplate, $sBlock, $iPosition, $sFile, $this->getModuleId()]
225235
);
226236
}
227237
}
@@ -235,29 +245,29 @@ public function fixBlocks()
235245
public function fixSettings()
236246
{
237247
$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();
241251

242252
// Cleanup !!!
243253
$oDb->execute(
244254
'DELETE FROM oxconfig WHERE oxmodule = ? AND oxshopid = ?',
245-
array(sprintf('module:%s', $this->getModuleId()), $sShopId)
255+
[sprintf('module:%s', $this->getModuleId()), $sShopId]
246256
);
247-
$oDb->execute('DELETE FROM oxconfigdisplay WHERE oxcfgmodule = ?', array($this->getModuleId()));
257+
$oDb->execute('DELETE FROM oxconfigdisplay WHERE oxcfgmodule = ?', [$this->getModuleId()]);
248258

249259
if (is_array($aModuleSettings)) {
250260

251261
foreach ($aModuleSettings as $aValue) {
252262
$sOxId = Registry::get('oxUtilsObject')->generateUId();
253263

254264
$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(
258268
$sName
259269
);
260-
$sGroup = $aValue['group'];
270+
$sGroup = $aValue['group'];
261271

262272
$sConstraints = '';
263273
if ($aValue['constraints']) {
@@ -278,7 +288,7 @@ public function fixSettings()
278288
(?, ?, ?, ?, ?, ?)
279289
';
280290

281-
$oDb->execute($sInsertSql, array($sOxId, $sModule, $sName, $sGroup, $sConstraints, $iPosition));
291+
$oDb->execute($sInsertSql, [$sOxId, $sModule, $sName, $sGroup, $sConstraints, $iPosition]);
282292
}
283293
}
284294

@@ -291,10 +301,10 @@ public function fixSettings()
291301
public function fixEvents()
292302
{
293303
$aModuleEvents = $this->getInfo('events');
294-
$aEvents = (array)Registry::getConfig()->getConfigParam('aModuleEvents');
304+
$aEvents = (array) Registry::getConfig()->getConfigParam('aModuleEvents');
295305

296306
if (is_array($aEvents)) {
297-
$aEvents[$this->getModuleId()] = $aModuleEvents;
307+
$aEvents[ $this->getModuleId() ] = $aModuleEvents;
298308
}
299309

300310
$this->_saveToConfig('aModuleEvents', $aEvents);
@@ -323,16 +333,16 @@ protected function _mergeModuleArrays($aAllModuleArray, $aAddModuleArray)
323333
if (is_array($aAllModuleArray) && is_array($aAddModuleArray)) {
324334
foreach ($aAddModuleArray as $sClass => $aModuleChain) {
325335
if (!is_array($aModuleChain)) {
326-
$aModuleChain = array($aModuleChain);
336+
$aModuleChain = [$aModuleChain];
327337
}
328-
if (isset($aAllModuleArray[$sClass])) {
338+
if (isset($aAllModuleArray[ $sClass ])) {
329339
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;
332342
}
333343
}
334344
} else {
335-
$aAllModuleArray[$sClass] = $aModuleChain;
345+
$aAllModuleArray[ $sClass ] = $aModuleChain;
336346
}
337347
}
338348
}
@@ -368,11 +378,11 @@ protected function removeExtendedClassesOfModule($aInstalledModules, $sModulePat
368378
if ($this->getModule()->checkMetaDataVersion('2.0')) {
369379
$moduleNameSpace = $this->getModule()->getModuleNameSpace($sModulePath);
370380
if (strpos($sModuleClassName, $moduleNameSpace) !== false) {
371-
unset($aInstalledModules[$shopClassName][$sKey]);
381+
unset($aInstalledModules[ $shopClassName ][ $sKey ]);
372382
}
373383
} else {
374384
if (strpos($sModuleClassName, $sModulePath . '/') === 0) {
375-
unset($aInstalledModules[$shopClassName][$sKey]);
385+
unset($aInstalledModules[ $shopClassName ][ $sKey ]);
376386
}
377387
}
378388
}

0 commit comments

Comments
 (0)