| Conditions | 2 |
| Paths | 2 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public function boot() |
||
| 15 | { |
||
| 16 | // If app config is already cached, simply use the cached config key/values. |
||
| 17 | // You will have to clear config cache to merge new database config |
||
| 18 | // values with application config and cache them again. |
||
| 19 | if (!file_exists($this->app->getCachedConfigPath())) { |
||
| 20 | // Load database config |
||
| 21 | $databaseConfig = $this->app['cache']->rememberForever( |
||
| 22 | $this->app['config']->get('database-config.cache_key'), |
||
| 23 | function () { |
||
| 24 | return DatabaseConfig::all() |
||
| 25 | ->mapWithKeys(function ($config) { |
||
| 26 | return [$config->name => $config->value]; |
||
| 27 | }) |
||
| 28 | ->all(); |
||
| 29 | } |
||
| 30 | ); |
||
| 31 | |||
| 32 | $config = $this->app['config']->all(); |
||
| 33 | $items = array_merge_recursive_distinct($config, $databaseConfig); |
||
| 34 | $repository = new Repository($items); |
||
| 35 | |||
| 36 | // Register custom instance in container |
||
| 37 | $this->app->instance('config', $repository); |
||
| 38 | } |
||
| 41 |