Skip to content
Permalink
Browse files

reset config

  • Loading branch information...
glzjin committed Mar 30, 2018
1 parent eb9b808 commit 82d16c71abc11fdf8aebd7083aa5de7dd381fa54
Showing with 40 additions and 0 deletions.
  1. +40 −0 src/Illuminate/Laravel.php
@@ -19,6 +19,8 @@ class Laravel
*/
protected $laravelKernel;
protected $laravel_conf = null;
protected $conf = [];
protected static $staticBlackList = [
@@ -230,9 +232,47 @@ public function cleanRequest(IlluminateRequest $request)
$this->app->forgetInstance('request');
Facade::clearResolvedInstance('request');
$this->flushConfig();
$this->loadConfig($this->conf['rootPath']. '/config');
//...
}
public function loadConfig($configFolder, $namespace = null)
{
if($this->laravel_conf != null) {
foreach($this->laravel_conf as $name => $config) {
$this->app['config']->set($namespace . $name , $config);
}
return;
}
$this->laravel_conf = array();
$files = $this->app['files']->files($configFolder);
$namespace = $namespace ? $namespace . '::' : '';
foreach($files as $file) {
$config = $this->app['files']->getRequire($file);
$name = $this->app['files']->name($file);
// special case for files named config.php (config keyword is omitted)
if($name === 'config') {
foreach($config as $key => $value) $this->app['config']->set($namespace . $key , $value);
}
$this->app['config']->set($namespace . $name , $config);
$this->laravel_conf[$name] = $config;
}
}
public function flushConfig()
{
foreach($this->app['config'] as $config) {
unset($this->app['config'][$config]);
}
}
public function fireEvent($name, array $params = [])
{
$params[] = $this->app;

0 comments on commit 82d16c7

Please sign in to comment.
You can’t perform that action at this time.