Completed
Push — master ( f442aa...39a78d )
by Sergi Tur
02:18
created

AdminLTETemplateServiceProvider::publishTests()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
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 Illuminate\Console\AppNamespaceDetectorTrait;
6
use Illuminate\Support\ServiceProvider;
7
use Acacha\AdminLTETemplateLaravel\Facades\AdminLTE;
8
9
/**
10
 * Class AdminLTETemplateServiceProvider.
11
 */
12
class AdminLTETemplateServiceProvider extends ServiceProvider
13
{
14
    use AppNamespaceDetectorTrait;
15
16
    /**
17
     * Register the application services.
18
     */
19
    public function register()
20
    {
21
        if (!defined('ADMINLTETEMPLATE_PATH')) {
22
            define('ADMINLTETEMPLATE_PATH', realpath(__DIR__.'/../../'));
23
        }
24
25
        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...
26
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTE::class]);
27
        }
28
29
        $this->app->bind('AdminLTE', function () {
30
            return new \Acacha\AdminLTETemplateLaravel\AdminLTE();
31
        });
32
    }
33
34
    /**
35
     * Bootstrap the application services.
36
     */
37
    public function boot()
38
    {
39
        $this->app->booted(function () {
40
            $this->defineRoutes();
41
        });
42
43
        $this->publishHomeController();
44
        $this->changeAuthController();
45
        $this->publishPublicAssets();
46
        $this->publishViews();
47
        $this->publishResourceAssets();
48
        $this->publishTests();
49
    }
50
51
    /**
52
     * Define the AdminLTETemplate routes.
53
     */
54
    protected function defineRoutes()
55
    {
56
        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...
57
            $router = app('router');
58
59
            $router->group(['namespace' => $this->getAppNamespace().'Http\Controllers'], function () {
60
                require __DIR__.'/../Http/routes.php';
61
            });
62
        }
63
    }
64
65
    /**
66
     * Publish Home Controller.
67
     */
68
    private function publishHomeController()
69
    {
70
        $this->publishes(AdminLTE::homeController(), 'adminlte');
71
    }
72
73
    /**
74
     * Change default Laravel AuthController.
75
     */
76
    private function changeAuthController()
77
    {
78
        $this->publishes(AdminLTE::authController(), 'adminlte');
79
    }
80
81
    /**
82
     * Publish public resource assets to Laravel project.
83
     */
84
    private function publishPublicAssets()
85
    {
86
        $this->publishes(AdminLTE::publicAssets(), 'adminlte');
87
    }
88
89
    /**
90
     * Publish package views to Laravel project.
91
     */
92
    private function publishViews()
93
    {
94
        $this->loadViewsFrom(ADMINLTETEMPLATE_PATH.'/resources/views/', 'adminlte');
95
96
        $this->publishes(AdminLTE::views(), 'adminlte');
97
    }
98
99
    /**
100
     * Publish package resource assets to Laravel project.
101
     */
102
    private function publishResourceAssets()
103
    {
104
        $this->publishes(AdminLTE::resourceAssets(), 'adminlte');
105
    }
106
107
    /**
108
     * Publish package tests to Laravel project.
109
     */
110
    private function publishTests()
111
    {
112
        $this->publishes(AdminLTE::tests(), 'adminlte');
113
    }
114
}
115