Passed
Push — master ( 32ec39...4f5ed5 )
by Aranea
38:11 queued 23:10
created

ElectrumServiceProvider::boot()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace AraneaDev\Electrum;
4
5
use Illuminate\Support\ServiceProvider;
6
use AraneaDev\Electrum\App\Console\Kernel;
7
use Illuminate\Contracts\Events\Dispatcher;
8
use AraneaDev\Electrum\App\Console\ElectrumCommand;
9
10
/**
11
 * Class ElectrumServiceProvider.
12
 */
13
class ElectrumServiceProvider extends ServiceProvider
14
{
15
    /**
16
     * Bootstrap the application services.
17
     *
18
     * @return void
19
     */
20
    public function boot()
21
    {
22
        // Bind the package routes
23
        include __DIR__.'/routes/electrum.php';
24
25
        // Bind the console commands
26
        if ($this->app->runningInConsole()) {
27
            $this->commands([
28
                ElectrumCommand::class,
29
            ]);
30
        }
31
    }
32
33
    /**
34
     * Register the application services.
35
     *
36
     * @return void
37
     */
38
    public function register()
39
    {
40
        // Merge the package configuration
41
        $this->mergeConfigFrom(
42
            __DIR__.'/config/electrum.php', 'electrum'
43
        );
44
45
        // Load the package views
46
        $this->loadViewsFrom(__DIR__.'/views', 'electrum');
47
48
        // Make the package controller
49
        $this->app->make('AraneaDev\Electrum\App\Http\Controllers\IndexController');
50
51
        // Make the package's custom task scheduling kernel
52
        $this->app->singleton('araneadev.electrum.app.console.kernel', function ($app) {
53
            $dispatcher = $app->make(Dispatcher::class);
54
55
            return new Kernel($app, $dispatcher);
56
        });
57
        $this->app->make('araneadev.electrum.app.console.kernel');
58
59
        // Publish the package assets
60
        $this->publish_assets();
61
    }
62
63
    /**
64
     * Publish the package assets.
65
     *
66
     * @return void
67
     */
68
    public function publish_assets()
69
    {
70
        $this->publishes([
71
            __DIR__.'/views'                            => resource_path('views/vendor/electrum'),
72
            __DIR__.'/resources/assets/js/Electrum.vue' => resource_path('assets/js/vendor/araneadev/Electrum.vue'),
73
        ], 'assets');
74
75
        $this->publishes([
76
            __DIR__.'/config/electrum.php' => config_path('electrum.php'),
77
        ], 'config');
78
    }
79
}
80