Completed
Push — master ( 33854f...b2df44 )
by Sergi Tur
05:19
created

AdminLTETemplateServiceProvider::publishGravatar()   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 Illuminate\Console\AppNamespaceDetectorTrait;
7
use Illuminate\Support\ServiceProvider;
8
use Creativeorange\Gravatar\GravatarServiceProvider;
9
use Creativeorange\Gravatar\Facades\Gravatar;
10
11
/**
12
 * Class AdminLTETemplateServiceProvider.
13
 */
14
class AdminLTETemplateServiceProvider extends ServiceProvider
15
{
16
    use AppNamespaceDetectorTrait;
17
18
    /**
19
     * Register the application services.
20
     */
21
    public function register()
22
    {
23
        if (!defined('ADMINLTETEMPLATE_PATH')) {
24
            define('ADMINLTETEMPLATE_PATH', realpath(__DIR__.'/../../'));
25
        }
26
27
        if ($this->app->runningInConsole()) {
0 ignored issues
show
Bug introduced by
The method runningInConsole() does not seem to exist on object<Illuminate\Contra...Foundation\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
28
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTE::class]);
29
        }
30
31
        $this->app->bind('AdminLTE', function () {
32
            return new \Acacha\AdminLTETemplateLaravel\AdminLTE();
33
        });
34
35
        $this->app->register(GravatarServiceProvider::class);
36
        class_alias(Gravatar::class, 'Gravatar');
37
    }
38
39
    /**
40
     * Bootstrap the application services.
41
     */
42
    public function boot()
43
    {
44
        $this->defineRoutes();
45
        $this->publishHomeController();
46
        $this->changeRegisterController();
47
        $this->publishPublicAssets();
48
        $this->publishViews();
49
        $this->publishResourceAssets();
50
        $this->publishTests();
51
        $this->publishLanguages();
52
        $this->publishGravatar();
53
    }
54
55
    /**
56
     * Define the AdminLTETemplate routes.
57
     */
58
    protected function defineRoutes()
59
    {
60
        if (!$this->app->routesAreCached()) {
0 ignored issues
show
Bug introduced by
The method routesAreCached() does not seem to exist on object<Illuminate\Contra...Foundation\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
61
            $router = app('router');
62
63
            $router->group(['namespace' => $this->getAppNamespace().'Http\Controllers'], function () {
64
                require __DIR__.'/../Http/routes.php';
65
            });
66
        }
67
    }
68
69
    /**
70
     * Publish Home Controller.
71
     */
72
    private function publishHomeController()
73
    {
74
        $this->publishes(AdminLTE::homeController(), 'adminlte');
75
    }
76
77
    /**
78
     * Change default Laravel RegisterController.
79
     */
80
    private function changeRegisterController()
81
    {
82
        $this->publishes(AdminLTE::registerController(), 'adminlte');
83
    }
84
85
    /**
86
     * Publish public resource assets to Laravel project.
87
     */
88
    private function publishPublicAssets()
89
    {
90
        $this->publishes(AdminLTE::publicAssets(), 'adminlte');
91
    }
92
93
    /**
94
     * Publish package views to Laravel project.
95
     */
96
    private function publishViews()
97
    {
98
        $this->loadViewsFrom(ADMINLTETEMPLATE_PATH.'/resources/views/', 'adminlte');
99
100
        $this->publishes(AdminLTE::views(), 'adminlte');
101
    }
102
103
    /**
104
     * Publish package resource assets to Laravel project.
105
     */
106
    private function publishResourceAssets()
107
    {
108
        $this->publishes(AdminLTE::resourceAssets(), 'adminlte');
109
    }
110
111
    /**
112
     * Publish package tests to Laravel project.
113
     */
114
    private function publishTests()
115
    {
116
        $this->publishes(AdminLTE::tests(), 'adminlte');
117
    }
118
119
    /**
120
     * Publish package language to Laravel project.
121
     */
122
    private function publishLanguages()
123
    {
124
        $this->loadTranslationsFrom(ADMINLTETEMPLATE_PATH.'/resources/lang/', 'adminlte_lang');
125
126
        $this->publishes([
127
            ADMINLTETEMPLATE_PATH.'/resources/lang/' => resource_path('lang/vendor/adminlte_lang'),
128
        ]);
129
    }
130
131
    /**
132
     * Publish config Gravatar file using group.
133
     */
134
    private function publishGravatar()
135
    {
136
        $this->publishes([ realpath(__DIR__.'/../config/gravatar.php') => config_path('gravatar.php') ], 'adminlte');
137
    }
138
}
139