FoundationServiceProvider::provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php namespace Arcanesoft\Foundation;
2
3
use Arcanesoft\Core\Bases\PackageServiceProvider;
4
5
/**
6
 * Class     FoundationServiceProvider
7
 *
8
 * @package  Arcanesoft\Foundation
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class FoundationServiceProvider extends PackageServiceProvider
12
{
13
    /* -----------------------------------------------------------------
14
     |  Properties
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * Package name.
20
     *
21
     * @var string
22
     */
23
    protected $package = 'foundation';
24
25
    /* -----------------------------------------------------------------
26
     |  Main Methods
27
     | -----------------------------------------------------------------
28
     */
29
30
    /**
31
     * Register the service provider.
32
     */
33 14
    public function register()
34
    {
35 14
        parent::register();
36
37 14
        $this->registerConfig();
38 14
        $this->registerSidebarItems();
39
40 14
        $this->registerProviders([
41 14
            Providers\PackagesServiceProvider::class,
42
            Providers\AuthorizationServiceProvider::class,
43
            Providers\RouteServiceProvider::class,
44
            Providers\ViewComposerServiceProvider::class,
45
        ]);
46 14
        $this->registerModuleProviders();
47 14
        $this->registerConsoleServiceProvider(Providers\CommandServiceProvider::class);
48
49 14
        $this->registerFoundationService();
50 14
    }
51
52
    /**
53
     * Boot the service provider.
54
     */
55 14
    public function boot()
56
    {
57 14
        parent::boot();
58
59
        // Publishes
60 14
        $this->publishConfig();
61 14
        $this->publishViews();
62 14
        $this->publishTranslations();
63 14
        $this->publishSidebarItems();
64 14
    }
65
66
    /**
67
     * Get the services provided by the provider.
68
     *
69
     * @return array
70
     */
71 2
    public function provides()
72
    {
73
        return [
74 2
            Contracts\Foundation::class,
75
        ];
76
    }
77
78
    /* -----------------------------------------------------------------
79
     |  Services Functions
80
     | -----------------------------------------------------------------
81
     */
82
83
    /**
84
     * Register Foundation service.
85
     */
86 14
    private function registerFoundationService()
87
    {
88 14
        $this->singleton(Contracts\Foundation::class, Foundation::class);
89 14
    }
90
91
    /**
92
     * Register ARCANESOFT's modules (providers).
93
     */
94 14
    private function registerModuleProviders()
95
    {
96 14
        $providers = $this->config()->get('arcanesoft.foundation.modules.providers', []);
97
98 14
        if (count($providers) > 0)
99 14
            $this->registerProviders($providers);
100 14
    }
101
}
102