Completed
Pull Request — master (#394)
by Elan
01:16
created

ConfigProvider::register()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 3
nc 1
nop 1
1
<?php
2
3
namespace XHGui\ServiceProvider;
4
5
use Pimple\Container;
6
use Pimple\ServiceProviderInterface;
7
use XHGui\Config;
8
9
class ConfigProvider implements ServiceProviderInterface
10
{
11
    public function register(Container $app)
12
    {
13
        $app['config'] = static function ($app) {
14
            // @deprecated
15
            // define XHGUI_ROOT_DIR constant, config files may use it
16
            if (!defined('XHGUI_ROOT_DIR')) {
17
                define('XHGUI_ROOT_DIR', $app['app.dir']);
18
            }
19
20
            Config::load($app['app.config_dir'] . '/config.default.php');
21
22
            if (file_exists($app['app.config_dir'] . '/config.php')) {
23
                Config::load($app['app.config_dir'] . '/config.php');
24
            }
25
26
            return Config::all();
27
        };
28
    }
29
}
30