KustomerServiceProvider   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 123
Duplicated Lines 0 %

Importance

Changes 5
Bugs 1 Features 1
Metric Value
eloc 40
c 5
b 1
f 1
dl 0
loc 123
rs 10
wmc 9

8 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 9 1
A registerMigrations() 0 3 1
A registerPublishing() 0 25 1
A routeConfiguration() 0 7 1
A registerTranslations() 0 3 1
A registerViews() 0 3 1
A registerRoutes() 0 4 1
A boot() 0 10 2
1
<?php
2
3
namespace Mydnic\Kustomer;
4
5
use Illuminate\Support\Facades\Route;
6
use Illuminate\Support\ServiceProvider;
7
8
class KustomerServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap any package services.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        if ($this->app->runningInConsole()) {
18
            $this->registerPublishing();
19
        }
20
21
        $this->registerRoutes();
22
        $this->registerMigrations();
23
        $this->registerTranslations();
24
        $this->registerViews();
25
    }
26
27
    /**
28
     * Register the package's publishable resources.
29
     *
30
     * @return void
31
     */
32
    protected function registerPublishing()
33
    {
34
        $this->publishes([
35
            __DIR__ . '/../config/kustomer.php' => config_path('kustomer.php'),
36
        ], 'kustomer-config');
37
38
        $this->publishes([
39
            __DIR__ . '/../public' => public_path('vendor/kustomer'),
40
        ], 'kustomer-assets');
41
42
        $this->publishes([
43
            __DIR__ . '/../resources/js/components' => resource_path('js/components/Kustomer'),
44
        ], 'kustomer-vue-component');
45
46
        $this->publishes([
47
            __DIR__ . '/../resources/sass' => resource_path('sass'),
48
        ], 'kustomer-sass-component');
49
50
        $this->publishes([
51
            __DIR__ . '/../resources/lang' => resource_path('lang/vendor/kustomer'),
52
        ], 'kustomer-locales');
53
54
        $this->publishes(
55
            [__DIR__ . '/../resources/views' => resource_path('views/vendor/kustomer')],
56
            'kustomer-views'
57
        );
58
    }
59
60
    /**
61
     * Register the package's migrations
62
     *
63
     * @return void
64
     */
65
    protected function registerMigrations()
66
    {
67
        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
68
    }
69
70
    /**
71
     * Register the package routes.
72
     *
73
     * @return void
74
     */
75
    protected function registerRoutes()
76
    {
77
        Route::group($this->routeConfiguration(), function () {
78
            $this->loadRoutesFrom(__DIR__ . '/../routes/api.php');
79
        });
80
    }
81
82
    /**
83
     * Register the package translations.
84
     *
85
     * @return void
86
     */
87
    protected function registerTranslations()
88
    {
89
        $this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'kustomer');
90
    }
91
92
    /**
93
     * Register the package views.
94
     *
95
     * @return void
96
     */
97
    public function registerViews()
98
    {
99
        $this->loadViewsFrom(__DIR__ . '/../resources/views', 'kustomer');
100
    }
101
102
    /**
103
     * Get the Kustomer route group configuration array.
104
     *
105
     * @return array
106
     */
107
    protected function routeConfiguration()
108
    {
109
        return [
110
            'namespace' => 'Mydnic\Kustomer\Http\Controllers',
111
            'as' => 'kustomer.api.',
112
            'prefix' => 'kustomer-api',
113
            'middleware' => 'web',
114
        ];
115
    }
116
117
    /**
118
     * Register any package services.
119
     *
120
     * @return void
121
     */
122
    public function register()
123
    {
124
        $this->mergeConfigFrom(
125
            __DIR__ . '/../config/kustomer.php',
126
            'kustomer'
127
        );
128
129
        $this->commands([
130
            Console\PublishCommand::class,
131
        ]);
132
    }
133
}
134