Skip to content

Commit

Permalink
Merge pull request #14 from OXIDprojects/make-console-work-with-broke…
Browse files Browse the repository at this point in the history
…n-config

Make console work with broken config
  • Loading branch information
keywan-ghadami-oxid authored Dec 12, 2018
2 parents 390893f + 23806b2 commit 73ab3b8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog for OXID Console

## [v5.3.0]
### Changed
- Console runs even if shop has a broken configuration
- Version is read by composers installed.json

## [v5.2.0]
### Added
- Support for commands registered via services.yaml of other composer packages
Expand Down
13 changes: 13 additions & 0 deletions bin/oxid
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ try {

loadBootstrap();

$oConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
$aLanguages = $oConfig->getConfigParam('aLanguages');
$aLanguageParams = $oConfig->getConfigParam('aLanguageParams');

if (false === $aLanguagesParams) {
echo 'Config Param for aLanguagesParams is broken. Setting default Values to de';
$oConfig->saveShopConfVar('aarr', 'aLanguageParams', ['de' => ['baseId' => 0 , 'active' => 1 , 'sort' => 1]]);
}
if (false === $aLanguages) {
echo 'Config Param for aLanguages is broken. Setting default Values to de';
$oConfig->saveShopConfVar('aarr', 'aLanguages', ['de' => 'Deutsch']);
}

$v = new VersionHelper;
$version = $v->getVersion('oxid-professional-services/oxid-console');

Expand Down
2 changes: 1 addition & 1 deletion src/Command/GenerateModuleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function configure()
->setAliases(['g:module'])
->setDescription('Generate new module scaffold');

$this->init();
}

private function init()
Expand All @@ -69,6 +68,7 @@ private function init()
*/
public function execute(InputInterface $input, OutputInterface $output)
{
$this->init();
$this->input = $input;
$this->output = $output;

Expand Down
12 changes: 9 additions & 3 deletions src/Core/CommandCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,15 @@ private function getCommandsFromModules()
if (! class_exists(ModuleList::class)) {
print "ERROR: Oxid ModuleList class can not be loaded, please run vendor/bin/oe-eshop-unified_namespace_generator";
} else {
$moduleList = oxNew(ModuleList::class);
$modulesDir = $oConfig->getModulesDir();
$moduleList->getModulesFromDir($modulesDir);
try {
$moduleList = oxNew(ModuleList::class);
$modulesDir = $oConfig->getModulesDir();
$moduleList->getModulesFromDir($modulesDir);
} catch (\Throwable $exception) {
print "Shop is not able to list modules\n";
print $exception->getMessage();
return [];
}
}

$paths = $this->getPathsOfAvailableModules();
Expand Down
6 changes: 2 additions & 4 deletions src/Core/Composer/VersionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ function getVersion($packageName)
{
$fullPath = __FILE__;
$vendorDir = dirname(dirname(dirname(dirname(dirname(dirname($fullPath))))));
$rootDir = dirname($vendorDir);
$fileName = $rootDir . '/composer.lock';
$fileName = $vendorDir . '/composer/installed.json';
$content = file_get_contents($fileName);
$content = json_decode($content, true);
$packages = $content['packages'];
$packages = json_decode($content, true);
$version = null;
foreach ($packages as $package) {
if ($package['name'] == $packageName) {
Expand Down

0 comments on commit 73ab3b8

Please sign in to comment.