From 73857d96975bccc940a6278d32f664c0d466e69b Mon Sep 17 00:00:00 2001 From: Alfred Bez Date: Thu, 9 Mar 2017 12:48:17 +0100 Subject: [PATCH] added `-s` or `--skip-settings` flag to `fix:states` command --- CHANGELOG.md | 1 + copy_this/application/commands/fixstatescommand.php | 13 ++++++++----- copy_this/core/oxmodulestatefixer.php | 6 ++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fca8c6..89df8a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ To get the diff for a specific change, go to https://github.com/EllisV/oxid-cons To get the diff between two versions, go to https://github.com/EllisV/oxid-console/compare/v1.2.4...v1.2.5 * 1.2.6 (not released yet) + * added `-s` or `--skip-settings` flag to `fix:states` command * (9a94f32) Support camel cased command file names * 1.2.5 (2016-11-25) diff --git a/copy_this/application/commands/fixstatescommand.php b/copy_this/application/commands/fixstatescommand.php index 32cf9d4..6a289c9 100644 --- a/copy_this/application/commands/fixstatescommand.php +++ b/copy_this/application/commands/fixstatescommand.php @@ -39,10 +39,11 @@ public function help(oxIOutput $oOutput) $oOutput->writeLn('This command fixes information stored in database of modules'); $oOutput->writeln(); $oOutput->writeLn('Available options:'); - $oOutput->writeLn(' -a, --all Passes all modules'); - $oOutput->writeLn(' -b, --base-shop Fix only on base shop'); - $oOutput->writeLn(' --shop= Specifies in which shop to fix states'); - $oOutput->writeLn(' -n, --no-debug No debug output'); + $oOutput->writeLn(' -a, --all Passes all modules'); + $oOutput->writeLn(' -b, --base-shop Fix only on base shop'); + $oOutput->writeLn(' --shop= Specifies in which shop to fix states'); + $oOutput->writeLn(' -n, --no-debug No debug output'); + $oOutput->writeLn(' -s, --skip-settings Don\'t reset module settings'); } /** @@ -55,6 +56,8 @@ public function execute(oxIOutput $oOutput) ? oxNew('oxNullOutput') : $oOutput; + $resetSettings = !$oInput->hasOption(array('s', 'skip-settings')); + try { $aModuleIds = $this->_parseModuleIds(); $aShopConfigs = $this->_parseShopConfigs(); @@ -80,7 +83,7 @@ public function execute(oxIOutput $oOutput) } $oDebugOutput->writeLn("[DEBUG] Fixing {$sModuleId} module"); - $oModuleStateFixer->fix($oModule, $oConfig); + $oModuleStateFixer->fix($oModule, $oConfig, $resetSettings); } $oDebugOutput->writeLn(); diff --git a/copy_this/core/oxmodulestatefixer.php b/copy_this/core/oxmodulestatefixer.php index ac6566c..41b8ef7 100644 --- a/copy_this/core/oxmodulestatefixer.php +++ b/copy_this/core/oxmodulestatefixer.php @@ -21,7 +21,7 @@ class oxModuleStateFixer extends oxModuleInstaller * @param oxModule $oModule * @param oxConfig|null $oConfig If not passed uses default base shop config */ - public function fix(oxModule $oModule, oxConfig $oConfig = null) + public function fix(oxModule $oModule, oxConfig $oConfig = null, $resetSettings = true) { if ($oConfig !== null) { $this->setConfig($oConfig); @@ -40,7 +40,9 @@ public function fix(oxModule $oModule, oxConfig $oConfig = null) $this->_addTemplateBlocks($oModule->getInfo("blocks"), $sModuleId); $this->_addModuleFiles($oModule->getInfo("files"), $sModuleId); $this->_addTemplateFiles($oModule->getInfo("templates"), $sModuleId); - $this->_addModuleSettings($oModule->getInfo("settings"), $sModuleId); + if ($resetSettings) { + $this->_addModuleSettings($oModule->getInfo("settings"), $sModuleId); + } $this->_addModuleVersion($oModule->getInfo("version"), $sModuleId); $this->_addModuleEvents($oModule->getInfo("events"), $sModuleId);