Completed
Push — master ( 11ad20...a09f6d )
by Sergi Tur
05:23
created

publishResourceAssets()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Acacha\AdminLTETemplateLaravel\Providers;
4
5
use Acacha\AdminLTETemplateLaravel\Facades\AdminLTE;
6
use Acacha\User\Providers\GuestUserServiceProvider;
7
use Creativeorange\Gravatar\Facades\Gravatar;
8
use Creativeorange\Gravatar\GravatarServiceProvider;
9
use Illuminate\Console\AppNamespaceDetectorTrait;
10
use Illuminate\Support\ServiceProvider;
11
12
/**
13
 * Class AdminLTETemplateServiceProvider.
14
 */
15
class AdminLTETemplateServiceProvider extends ServiceProvider
16
{
17
    use AppNamespaceDetectorTrait;
18
19
    /**
20
     * Register the application services.
21
     */
22
    public function register()
23
    {
24
        if (!defined('ADMINLTETEMPLATE_PATH')) {
25
            define('ADMINLTETEMPLATE_PATH', realpath(__DIR__.'/../../'));
26
        }
27
28
        if ($this->app->runningInConsole()) {
29
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\PublishAdminLTE::class]);
30
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\PublishAdminLTEAlt::class]);
31
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\PublishAdminLTESidebar::class]);
32
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\PublishAdminLTESidebarAlt::class]);
33
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeAdminUserSeeder::class]);
34
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTEAdmin::class]);
35
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTEAdminAlt::class]);
36
        }
37
38
        $this->app->bind('AdminLTE', function () {
39
            return new \Acacha\AdminLTETemplateLaravel\AdminLTE();
40
        });
41
42
        if (config('adminlte.gravatar',true)) $this->registerGravatarServiceProvider();
43
44
        if (config('adminlte.guestuser',true)) $this->registerGuestUserProvider();
45
46
    }
47
48
    /**
49
     * Register Guest User Provider.
50
     */
51
    protected function registerGuestUserProvider() {
52
        $this->app->register(GuestUserServiceProvider::class);
53
    }
54
55
    /**
56
     * Register Gravatar Service Provider.
57
     */
58
    protected function registerGravatarServiceProvider()
59
    {
60
        $this->app->register(GravatarServiceProvider::class);
61
        if (!class_exists('Gravatar')) {
62
            class_alias(Gravatar::class, 'Gravatar');
63
        }
64
    }
65
66
    /**
67
     * Bootstrap the application services.
68
     */
69 View Code Duplication
    public function boot()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
70
    {
71
        $this->defineRoutes();
72
        $this->publishHomeController();
73
        $this->changeRegisterController();
74
        $this->changeLoginController();
75
        $this->changeForgotPasswordController();
76
        $this->changeResetPasswordController();
77
        $this->publishPublicAssets();
78
        $this->publishViews();
79
        $this->publishResourceAssets();
80
        $this->publishTests();
81
        $this->publishLanguages();
82
        $this->publishGravatar();
83
        $this->publishConfig();
84
    }
85
86
    /**
87
     * Define the AdminLTETemplate routes.
88
     */
89
    protected function defineRoutes()
90
    {
91
        if (!$this->app->routesAreCached()) {
92
            $router = app('router');
93
94
            $router->group(['namespace' => $this->getAppNamespace().'Http\Controllers'], function () {
95
                require __DIR__.'/../Http/routes.php';
96
            });
97
        }
98
    }
99
100
    /**
101
     * Publish Home Controller.
102
     */
103
    private function publishHomeController()
104
    {
105
        $this->publishes(AdminLTE::homeController(), 'adminlte');
106
    }
107
108
    /**
109
     * Change default Laravel RegisterController.
110
     */
111
    private function changeRegisterController()
112
    {
113
        $this->publishes(AdminLTE::registerController(), 'adminlte');
114
    }
115
116
    /**
117
     * Change default Laravel LoginController.
118
     */
119
    private function changeLoginController()
120
    {
121
        $this->publishes(AdminLTE::loginController(), 'adminlte');
122
    }
123
124
    /**
125
     * Change default Laravel forgot password Controller.
126
     */
127
    private function changeForgotPasswordController()
128
    {
129
        $this->publishes(AdminLTE::forgotPasswordController(), 'adminlte');
130
    }
131
132
    /**
133
     * Change default Laravel reset password Controller.
134
     */
135
    private function changeResetPasswordController()
136
    {
137
        $this->publishes(AdminLTE::resetPasswordController(), 'adminlte');
138
    }
139
140
    /**
141
     * Publish public resource assets to Laravel project.
142
     */
143
    private function publishPublicAssets()
144
    {
145
        $this->publishes(AdminLTE::publicAssets(), 'adminlte');
146
    }
147
148
    /**
149
     * Publish package views to Laravel project.
150
     */
151
    private function publishViews()
152
    {
153
        $this->loadViewsFrom(ADMINLTETEMPLATE_PATH.'/resources/views/', 'adminlte');
154
155
        $this->publishes(AdminLTE::views(), 'adminlte');
156
    }
157
158
    /**
159
     * Publish package resource assets to Laravel project.
160
     */
161
    private function publishResourceAssets()
162
    {
163
        $this->publishes(AdminLTE::resourceAssets(), 'adminlte');
164
    }
165
166
    /**
167
     * Publish package tests to Laravel project.
168
     */
169
    private function publishTests()
170
    {
171
        $this->publishes(AdminLTE::tests(), 'adminlte');
172
    }
173
174
    /**
175
     * Publish package language to Laravel project.
176
     */
177
    private function publishLanguages()
178
    {
179
        $this->loadTranslationsFrom(ADMINLTETEMPLATE_PATH.'/resources/lang/', 'adminlte_lang');
180
181
        $this->publishes(AdminLTE::languages(), 'adminlte_lang');
182
    }
183
184
    /**
185
     * Publish config Gravatar file using group.
186
     */
187
    private function publishGravatar()
188
    {
189
        $this->publishes(AdminLTE::gravatar(), 'adminlte');
190
    }
191
192
    /**
193
     * Publish adminlte package config.
194
     */
195
    private function publishConfig()
196
    {
197
        $this->publishes(AdminLTE::config(), 'adminlte');
198
    }
199
}
200