-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebind
Illuminate\Foundation\Bootstrap\LoadConfiguration
with `Orch…
…estra\Testbench\Bootstrap\LoadConfiguration`. Alternative solution to #77 Signed-off-by: crynobone <crynobone@gmail.com>
- Loading branch information
Showing
3 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php namespace Orchestra\Testbench\Bootstrap; | ||
|
||
use Illuminate\Config\Repository; | ||
use Symfony\Component\Finder\Finder; | ||
use Illuminate\Contracts\Foundation\Application; | ||
use Illuminate\Contracts\Config\Repository as RepositoryContract; | ||
|
||
class LoadConfiguration | ||
{ | ||
|
||
/** | ||
* Bootstrap the given application. | ||
* | ||
* @param \Illuminate\Contracts\Foundation\Application $app | ||
* @return void | ||
*/ | ||
public function bootstrap(Application $app) | ||
{ | ||
$items = []; | ||
|
||
$app->instance('config', $config = new Repository($items)); | ||
|
||
$this->loadConfigurationFiles($app, $config); | ||
|
||
date_default_timezone_set($config['app.timezone']); | ||
|
||
mb_internal_encoding('UTF-8'); | ||
} | ||
|
||
/** | ||
* Load the configuration items from all of the files. | ||
* | ||
* @param \Illuminate\Contracts\Foundation\Application $app | ||
* @param \Illuminate\Contracts\Config\Repository $config | ||
* @return void | ||
*/ | ||
protected function loadConfigurationFiles(Application $app, RepositoryContract $config) | ||
{ | ||
foreach ($this->getConfigurationFiles($app) as $key => $path) { | ||
$config->set($key, require $path); | ||
} | ||
} | ||
|
||
/** | ||
* Get all of the configuration files for the application. | ||
* | ||
* @param \Illuminate\Contracts\Foundation\Application $app | ||
* @return array | ||
*/ | ||
protected function getConfigurationFiles(Application $app) | ||
{ | ||
$files = []; | ||
|
||
foreach (Finder::create()->files()->name('*.php')->in($app->configPath()) as $file) { | ||
$files[basename($file->getRealPath(), '.php')] = $file->getRealPath(); | ||
} | ||
|
||
return $files; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters