Skip to content

Commit 36bbd55

Browse files
committed
fix: resolve path to custom config file
1 parent 4b36246 commit 36bbd55

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/AbstractKernel.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ abstract class AbstractKernel implements KernelInterface
3131
{
3232
public const CONFIG_FILE_PATH = __DIR__ . '/../emitron.config';
3333
protected static ?string $configFilePath = null;
34+
protected static ?string $routerFilePath = null;
3435
protected ContainerInterface $container;
3536
protected array $userMiddlewares;
3637
protected ?DispatchConfigInterface $dispatchConfig = null;
@@ -77,6 +78,30 @@ public static function getConfigFilePath(): string
7778
return static::$configFilePath;
7879
}
7980

81+
/**
82+
* Set router path
83+
*
84+
* @param string $path
85+
* @return void
86+
*/
87+
public static function setRouterFilePath(string $path): void
88+
{
89+
static::$routerFilePath = $path;
90+
}
91+
92+
/**
93+
* Get router path
94+
*
95+
* @return string
96+
*/
97+
public static function getRouterFilePath(): string
98+
{
99+
if(static::$routerFilePath === null) {
100+
return realpath(dirname(self::getConfigFilePath()));
101+
}
102+
return static::$routerFilePath;
103+
}
104+
80105
/**
81106
* Get config instance for configure dispatch result
82107
*

src/DispatchConfig.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ public function loadConfigFile(string $path): void
131131
throw new Exception('The config file do not return a array');
132132
}
133133

134-
$this->dir = realpath(dirname($path));
134+
//$this->dir = realpath(dirname($path));
135+
$this->dir = AbstractKernel::getRouterFilePath();
135136
$this->props = new ConfigProps($config);
136137
}
137138
}

0 commit comments

Comments
 (0)