Passed
Push — master ( 517bd8...f7cc98 )
by Attila
06:55
created

getDefaultModuleConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
/**
3
 * Contains the BaseBoxServiceProvider class.
4
 *
5
 * @copyright   Copyright (c) 2016 Attila Fulop
6
 * @author      Attila Fulop
7
 * @license     MIT
8
 * @since       2016-12-29
9
 *
10
 */
11
12
13
namespace Konekt\Concord;
14
15
abstract class BaseBoxServiceProvider extends BaseServiceProvider
16
{
17
    protected $configFileName = 'box.php';
18
19
    protected static $_kind = 'box';
20
21
    public function register()
22
    {
23
        parent::register();
24
25
        $modules = $this->config("modules");
26
        $modules = $modules ?: [];
27
28
        foreach ($modules as $module => $configuration) {
29
            if (is_int($module) && is_string($configuration)) { // means no configuration was set for module
30
                $module        = $configuration;
31
                $configuration = $this->getDefaultModuleConfiguration();
32
            } else {
33
                $configuration = array_merge($this->getDefaultModuleConfiguration(),
34
                    is_array($configuration) ? $configuration : []);
35
            }
36
37
            $this->concord->registerModule($module, $configuration);
38
        }
39
    }
40
41
    /**
42
     * Returns the default configuration settings for modules loaded within boxes
43
     *
44
     * @return array
45
     */
46
    protected function getDefaultModuleConfiguration()
47
    {
48
        return [
49
            'implicit'   => true,
50
            'migrations' => true,
51
            'views'      => true,
52
            'routes'     => true
53
        ];
54
    }
55
}
56