Passed
Push — master ( bd13ba...272332 )
by Sander
04:42 queued 02:26
created

GdprServiceProvider::registerCommands()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Soved\Laravel\Gdpr;
4
5
use Illuminate\Support\Facades\Route;
6
use Illuminate\Support\ServiceProvider;
7
use Soved\Laravel\Gdpr\Console\Commands\Cleanup;
8
9
class GdprServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application services.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        $this->registerRoutes();
19
        $this->registerCommands();
20
    }
21
22
    /**
23
     * Register the GDPR routes.
24
     *
25
     * @return void
26
     */
27
    protected function registerRoutes()
28
    {
29
        Route::group([
30
            'prefix'     => config('gdpr.uri'),
31
            'namespace'  => 'Soved\Laravel\Gdpr\Http\Controllers',
32
            'middleware' => config('gdpr.middleware'),
33
        ], function () {
34
            $this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
35
        });
36
    }
37
38
    /**
39
     * Register the GDPR commands.
40
     *
41
     * @return void
42
     */
43
    protected function registerCommands()
44
    {
45
        if ($this->app->runningInConsole()) {
46
            $this->commands([
47
                Cleanup::class,
48
            ]);
49
        }
50
    }
51
52
    /**
53
     * Register the application services.
54
     *
55
     * @return void
56
     */
57
    public function register()
58
    {
59
        $this->configure();
60
        $this->offerPublishing();
61
    }
62
63
    /**
64
     * Setup the configuration for GDPR.
65
     *
66
     * @return void
67
     */
68
    protected function configure()
69
    {
70
        $this->mergeConfigFrom(
71
            __DIR__ . '/../config/gdpr.php', 'gdpr'
72
        );
73
    }
74
75
    /**
76
     * Setup the resource publishing groups for GDPR.
77
     *
78
     * @return void
79
     */
80
    protected function offerPublishing()
81
    {
82
        if ($this->app->runningInConsole()) {
83
            $this->publishes([
84
                __DIR__ . '/../config/gdpr.php' => config_path('gdpr.php'),
85
            ], 'gdpr-config');
86
        }
87
    }
88
}
89