Completed
Push — master ( 60f6bb...393bf4 )
by Sergi Tur
25:56
created

changeResetPasswordController()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
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
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeView::class]);
37
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTEMenu::class]);
38
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTEMenuAlt::class]);
39
        }
40
41
        $this->app->bind('AdminLTE', function () {
42
            return new \Acacha\AdminLTETemplateLaravel\AdminLTE();
43
        });
44
45
        if (config('adminlte.gravatar', true)) {
46
            $this->registerGravatarServiceProvider();
47
        }
48
49
        if (config('adminlte.guestuser', true)) {
50
            $this->registerGuestUserProvider();
51
        }
52
    }
53
54
    /**
55
     * Register Guest User Provider.
56
     */
57
    protected function registerGuestUserProvider()
58
    {
59
        $this->app->register(GuestUserServiceProvider::class);
60
    }
61
62
    /**
63
     * Register Gravatar Service Provider.
64
     */
65
    protected function registerGravatarServiceProvider()
66
    {
67
        $this->app->register(GravatarServiceProvider::class);
68
        if (!class_exists('Gravatar')) {
69
            class_alias(Gravatar::class, 'Gravatar');
70
        }
71
    }
72
73
    /**
74
     * Bootstrap the application services.
75
     */
76 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...
77
    {
78
        $this->defineRoutes();
79
        $this->publishHomeController();
80
        $this->changeRegisterController();
81
        $this->changeLoginController();
82
        $this->changeForgotPasswordController();
83
        $this->changeResetPasswordController();
84
        $this->publishPublicAssets();
85
        $this->publishViews();
86
        $this->publishResourceAssets();
87
        $this->publishTests();
88
        $this->publishLanguages();
89
        $this->publishGravatar();
90
        $this->publishConfig();
91
        $this->enableSpatieMenu();
92
    }
93
94
    /**
95
     * Define the AdminLTETemplate routes.
96
     */
97
    protected function defineRoutes()
98
    {
99
        if (!$this->app->routesAreCached()) {
100
            $router = app('router');
101
102
            $router->group(['namespace' => $this->getAppNamespace().'Http\Controllers'], function () {
103
                require __DIR__.'/../Http/routes.php';
104
            });
105
        }
106
    }
107
108
    /**
109
     * Publish Home Controller.
110
     */
111
    private function publishHomeController()
112
    {
113
        $this->publishes(AdminLTE::homeController(), 'adminlte');
114
    }
115
116
    /**
117
     * Change default Laravel RegisterController.
118
     */
119
    private function changeRegisterController()
120
    {
121
        $this->publishes(AdminLTE::registerController(), 'adminlte');
122
    }
123
124
    /**
125
     * Change default Laravel LoginController.
126
     */
127
    private function changeLoginController()
128
    {
129
        $this->publishes(AdminLTE::loginController(), 'adminlte');
130
    }
131
132
    /**
133
     * Change default Laravel forgot password Controller.
134
     */
135
    private function changeForgotPasswordController()
136
    {
137
        $this->publishes(AdminLTE::forgotPasswordController(), 'adminlte');
138
    }
139
140
    /**
141
     * Change default Laravel reset password Controller.
142
     */
143
    private function changeResetPasswordController()
144
    {
145
        $this->publishes(AdminLTE::resetPasswordController(), 'adminlte');
146
    }
147
148
    /**
149
     * Publish public resource assets to Laravel project.
150
     */
151
    private function publishPublicAssets()
152
    {
153
        $this->publishes(AdminLTE::publicAssets(), 'adminlte');
154
    }
155
156
    /**
157
     * Publish package views to Laravel project.
158
     */
159
    private function publishViews()
160
    {
161
        $this->loadViewsFrom(ADMINLTETEMPLATE_PATH.'/resources/views/', 'adminlte');
162
163
        $this->publishes(AdminLTE::views(), 'adminlte');
164
    }
165
166
    /**
167
     * Publish package resource assets to Laravel project.
168
     */
169
    private function publishResourceAssets()
170
    {
171
        $this->publishes(AdminLTE::resourceAssets(), 'adminlte');
172
    }
173
174
    /**
175
     * Publish package tests to Laravel project.
176
     */
177
    private function publishTests()
178
    {
179
        $this->publishes(AdminLTE::tests(), 'adminlte');
180
    }
181
182
    /**
183
     * Publish package language to Laravel project.
184
     */
185
    private function publishLanguages()
186
    {
187
        $this->loadTranslationsFrom(ADMINLTETEMPLATE_PATH.'/resources/lang/', 'adminlte_lang');
188
189
        $this->publishes(AdminLTE::languages(), 'adminlte_lang');
190
    }
191
192
    /**
193
     * Publish config Gravatar file using group.
194
     */
195
    private function publishGravatar()
196
    {
197
        $this->publishes(AdminLTE::gravatar(), 'adminlte');
198
    }
199
200
    /**
201
     * Publish adminlte package config.
202
     */
203
    private function publishConfig()
204
    {
205
        $this->publishes(AdminLTE::config(), 'adminlte');
206
    }
207
208
    /**
209
     * Enable (if active) spatie menu.
210
     */
211
    protected function enableSpatieMenu()
212
    {
213
        if ($this->app->getProvider('Spatie\Menu\Laravel\MenuServiceProvider')) {
214
            require config_path('menu.php');
215
        }
216
    }
217
}
218