Skip to content
This repository was archived by the owner on Jan 7, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 21 additions & 25 deletions copy_this/application/commands/fixstatescommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
class FixStatesCommand extends oxConsoleCommand
{

/**
* @var array|null Available module ids
*/
protected $_aAvailableModuleIds = null;

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -56,7 +51,6 @@ public function execute(oxIOutput $oOutput)
: $oOutput;

try {
$aModuleIds = $this->_parseModuleIds();
$aShopConfigs = $this->_parseShopConfigs();
} catch (oxInputException $oEx) {
$oOutput->writeLn($oEx->getMessage());
Expand All @@ -67,8 +61,15 @@ public function execute(oxIOutput $oOutput)
$oStateFixerModule = oxNew('oxStateFixerModule');

foreach ($aShopConfigs as $oConfig) {

$oDebugOutput->writeLn('[DEBUG] Working on shop id ' . $oConfig->getShopId());
try {
$aModuleIds = $this->_parseModuleIds($oConfig);
} catch (oxInputException $oEx) {
$oOutput->writeLn($oEx->getMessage());
return;
}
$sShopId = $oConfig->getShopId();
$oDebugOutput->writeLn('[DEBUG] Working on shop id ' . $sShopId);
$oStateFixerModule->setConfig($oConfig);

foreach ($aModuleIds as $sModuleId) {
if (!$oStateFixerModule->load($sModuleId)) {
Expand All @@ -78,7 +79,6 @@ public function execute(oxIOutput $oOutput)

$oDebugOutput->writeLn("[DEBUG] Fixing {$sModuleId} module");

$oStateFixerModule->setConfig($oConfig);
$oStateFixerModule->fixVersion();
$oStateFixerModule->fixExtendGently();
$oStateFixerModule->fixFiles();
Expand All @@ -101,12 +101,12 @@ public function execute(oxIOutput $oOutput)
*
* @throws oxInputException
*/
protected function _parseModuleIds()
protected function _parseModuleIds($oConfig)
{
$oInput = $this->getInput();

if ($oInput->hasOption(array('a', 'all'))) {
return $this->_getAvailableModuleIds();
return $this->_getAvailableModuleIds($oConfig);
}

if (count($oInput->getArguments()) < 2) { // Note: first argument is command name
Expand All @@ -119,7 +119,7 @@ protected function _parseModuleIds()
$aModuleIds = $oInput->getArguments();
array_shift($aModuleIds); // Getting rid of command name argument

$aAvailableModuleIds = $this->_getAvailableModuleIds();
$aAvailableModuleIds = $this->_getAvailableModuleIds($oConfig);

// Checking if all provided module ids exist
foreach ($aModuleIds as $sModuleId) {
Expand Down Expand Up @@ -177,19 +177,15 @@ protected function _parseShopConfigs()
*
* @return array
*/
protected function _getAvailableModuleIds()
protected function _getAvailableModuleIds($oConfig)
{
if ($this->_aAvailableModuleIds === null) {
$oConfig = oxRegistry::getConfig();

// We are calling getModulesFromDir() because we want to refresh
// the list of available modules. This is a workaround for OXID
// bug.
oxNew('oxModuleList')->getModulesFromDir($oConfig->getModulesDir());

$this->_aAvailableModuleIds = array_keys($oConfig->getConfigParam('aModulePaths'));
}

return $this->_aAvailableModuleIds;
// We are calling getModulesFromDir() because we want to refresh
// the list of available modules. This is a workaround for OXID
// bug.
$oModuleList = oxNew('oxModuleList');
$oModuleList->setConfig($oConfig);
$oModuleList->getModulesFromDir($oConfig->getModulesDir());

return array_keys($oConfig->getConfigParam('aModulePaths'));
}
}