Skip to content

Commit

Permalink
throw exception if config from file is wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
Pathologic authored May 9, 2023
1 parent b8b08ed commit 72a8751
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions assets/lib/Helpers/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use jsonHelper;
use APIhelpers;
use Exception;

class Config
{
Expand Down Expand Up @@ -71,8 +72,11 @@ public function loadConfig($name)
if ($this->fs->checkFile($configFile)) {
$json = file_get_contents(MODX_BASE_PATH . $configFile);
/** @var array $json */
$json = jsonHelper::jsonDecode($json, array('assoc' => true), true);
$config = array_merge($config, $json);
$_json = jsonHelper::jsonDecode($json, array('assoc' => true), true);
if(empty($json) || empty($_json)) {
throw new Exception($configFile . ' is empty or has errors');
}
$config = array_merge($config, $_json);
}
}

Expand Down

0 comments on commit 72a8751

Please sign in to comment.