Skip to content

Commit

Permalink
fix broken config loading
Browse files Browse the repository at this point in the history
  • Loading branch information
boxblinkracer committed Dec 19, 2024
1 parent f79e494 commit d0d8c40
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ private static function getConfigurationPath(array $args): ?string
*/
private static function loadBootstrap(string $configPath): void
{
$configPath = self::getConfigFile($configPath);

if (!file_exists($configPath)) {
throw new Exception("Configuration file not found: $configPath");
}
Expand All @@ -143,4 +145,21 @@ private static function loadBootstrap(string $configPath): void
throw new ConfigurationException('Bootstrap file not found: ' . $bootstrapFixedFilename);
}
}

/**
* TODO this is duplicate code from CommandTrait.php, but for now it works
*/
private static function getConfigFile(string $configFile): string
{
$configFile = trim($configFile);

if ($configFile === '' || $configFile === '0') {
$configFile = 'phpunuhi.xml';
}

$cur_dir = explode('\\', (string)getcwd());
$workingDir = $cur_dir[count($cur_dir) - 1];

return $workingDir . '/' . $configFile;
}
}

0 comments on commit d0d8c40

Please sign in to comment.