ServiceProvider   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 18
c 2
b 0
f 0
dl 0
loc 63
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 5 1
A registerPublishes() 0 17 2
A registerRoutes() 0 10 2
A register() 0 3 1
1
<?php
2
3
namespace Spinen\Formio\Providers;
4
5
use Illuminate\Support\Facades\Config;
6
use Illuminate\Support\Facades\Route;
7
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
8
9
/**
10
 * Class ServiceProvider
11
 *
12
 * @package Spinen\Formio\Providers
13
 */
14
class ServiceProvider extends LaravelServiceProvider
15
{
16
    /**
17
     * Bootstrap services.
18
     *
19
     * @return void
20
     */
21
    public function boot()
22
    {
23
        $this->registerPublishes();
24
25
        $this->registerRoutes();
26
    }
27
28
    /**
29
     * Register services.
30
     *
31
     * @return void
32
     */
33
    public function register()
34
    {
35
        $this->mergeConfigFrom(__DIR__ . '/../../config/formio.php', 'formio');
36
    }
37
38
    /**
39
     * There are several resources that get published
40
     *
41
     * Only worry about telling the application about them if running in the console.
42
     */
43
    protected function registerPublishes()
44
    {
45
        if ($this->app->runningInConsole()) {
46
            $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations');
47
48
            $this->publishes(
49
                [
50
                    __DIR__ . '/../../config/formio.php' => config_path('formio.php'),
51
                ],
52
                'formio-config'
53
            );
54
55
            $this->publishes(
56
                [
57
                    __DIR__ . '/../../database/migrations' => database_path('migrations'),
58
                ],
59
                'formio-migrations'
60
            );
61
        }
62
    }
63
64
    /**
65
     * Register the routes needed for the registration flow
66
     */
67
    protected function registerRoutes()
68
    {
69
        if (Config::get('formio.route.enabled')) {
70
            Route::group(
71
                [
72
                    'namespace'  => 'Spinen\Formio\Http\Controllers',
73
                    'middleware' => Config::get('formio.route.middleware', ['api', 'auth:api']),
74
                ],
75
                function () {
76
                    $this->loadRoutesFrom(realpath(__DIR__ . '/../../routes/web.php'));
77
                }
78
            );
79
        }
80
    }
81
}
82