Config::get()   B
last analyzed

Complexity

Conditions 7
Paths 64

Size

Total Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 38
rs 8.3786
c 0
b 0
f 0
cc 7
nc 64
nop 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2011 - 2015 Oleksandr Torosh (http://yonastudio.com)
4
 * @author Oleksandr Torosh <[email protected]>
5
 */
6
7
namespace Cms;
8
9
class Config
10
{
11
12
    public static function get()
13
    {
14
        $application = include_once APPLICATION_PATH . '/config/environment/' . APPLICATION_ENV . '.php';
15
16
        $config_default = [
17
            'loader'    => [
18
                'namespaces' => [
19
                    'YonaCMS\Plugin' => APPLICATION_PATH . '/plugins/',
20
                    'Application'    => APPLICATION_PATH . '/modules/Application',
21
                    'Cms'            => APPLICATION_PATH . '/modules/Cms',
22
                ],
23
            ],
24
            'modules'   => [
25
                'cms' => [
26
                    'className' => 'Cms\Module',
27
                    'path'      => APPLICATION_PATH . '/modules/Cms/Module.php'
28
                ],
29
            ],
30
            'base_path' => (isset($application['base_path'])) ? $application['base_path'] : null,
31
            'database'  => (isset($application['database'])) ? $application['database'] : null,
32
            'cache'     => (isset($application['cache'])) ? $application['cache'] : null,
33
            'memcache'  => (isset($application['memcache'])) ? $application['memcache'] : null,
34
            'memcached'  => (isset($application['memcached'])) ? $application['memcached'] : null,
35
            'assets'    => (isset($application['assets'])) ? $application['assets'] : null,
36
        ];
37
38
        $global = include_once APPLICATION_PATH . '/config/global.php';
39
40
        // Modules configuration list
41
        $modules_list = include_once APPLICATION_PATH . '/config/modules.php';
42
        require_once APPLICATION_PATH . '/modules/Application/Loader/Modules.php';
43
        $modules = new \Application\Loader\Modules();
44
        $modules_config = $modules->modulesConfig($modules_list);
45
46
        $config = array_merge_recursive($config_default, $global, $modules_config);
47
48
        return new \Phalcon\Config($config);
49
    }
50
51
}
52