Completed
Push — master ( 8dcf54...5429f1 )
by ARCANEDEV
08:51
created

FoundationServiceProvider::getConfigKey()   A

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
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
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
     * Package name.
19
     *
20
     * @var string
21
     */
22
    protected $package      = 'foundation';
23
24
    /* ------------------------------------------------------------------------------------------------
25
     |  Getters & Setters
26
     | ------------------------------------------------------------------------------------------------
27
     */
28
    /**
29
     * Get the base path of the package.
30
     *
31
     * @return string
32
     */
33 24
    public function getBasePath()
34
    {
35 24
        return dirname(__DIR__);
36
    }
37
38
    /* ------------------------------------------------------------------------------------------------
39
     |  Main Functions
40
     | ------------------------------------------------------------------------------------------------
41
     */
42
    /**
43
     * Register the service provider.
44
     */
45 24
    public function register()
46
    {
47 24
        $this->registerConfig();
48
49 24
        $this->app->register(\Arcanesoft\Core\CoreServiceProvider::class);
50 24
        $this->app->register(Providers\PackagesServiceProvider::class);
51 24
        $this->app->register(Providers\ModuleServiceProvider::class);
52 24
        $this->app->register(Providers\AuthorizationServiceProvider::class);
53 24
        $this->registerFoundationService();
54
55 24
        if ($this->app->runningInConsole()) {
56 24
            $this->app->register(Providers\CommandServiceProvider::class);
57 18
        }
58 24
    }
59
60
    /**
61
     * Boot the service provider.
62
     */
63 24
    public function boot()
64
    {
65 24
        $this->registerPublishes();
66
67 24
        $this->app->register(Providers\RouteServiceProvider::class);
68 24
    }
69
70
    /**
71
     * Get the services provided by the provider.
72
     *
73
     * @return array
74
     */
75 4
    public function provides()
76
    {
77
        return [
78 4
            'arcanesoft.foundation',
79 3
        ];
80
    }
81
82
    /* ------------------------------------------------------------------------------------------------
83
     |  Services Functions
84
     | ------------------------------------------------------------------------------------------------
85
     */
86
    /**
87
     * Register Foundation service.
88
     */
89 24
    private function registerFoundationService()
90
    {
91 24
        $this->singleton('arcanesoft.foundation', Foundation::class);
92 24
    }
93
94
    /* ------------------------------------------------------------------------------------------------
95
     |  Other Functions
96
     | ------------------------------------------------------------------------------------------------
97
     */
98 24
    private function registerPublishes()
99
    {
100 24
        $basePath = $this->getBasePath();
101
102
        // Config
103 24
        $this->publishes([
104 24
            $this->getConfigFile() => config_path($this->vendor . DS . "{$this->package}.php")
105 18
        ]);
106
107
        // Views
108 24
        $viewsPath = "$basePath/resources/views";
109 24
        $this->loadViewsFrom($viewsPath, 'foundation');
110 24
        $this->publishes([
111 24
            $viewsPath => base_path('resources/views/vendor/foundation'),
112 24
        ], 'views');
113
114
        // Translations
115 24
        $translationsPath = "$basePath/resources/lang";
116 24
        $this->loadTranslationsFrom($translationsPath, 'foundation');
117 24
        $this->publishes([
118 24
            $translationsPath => base_path('resources/lang/vendor/foundation'),
119 24
        ], 'lang');
120
121
        // Assets
122 24
        $this->publishes([
123 24
            "$basePath/resources/assets/dist" => public_path('vendor/foundation'),
124 24
        ], 'assets');
125 24
    }
126
}
127