Completed
Push — master ( f7d81c...d64534 )
by Jimmy
06:11 queued 02:27
created

ServiceProvider::provides()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
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'),
0 ignored issues
show
Bug introduced by
The function config_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
                    __DIR__ . '/../../config/formio.php' => /** @scrutinizer ignore-call */ config_path('formio.php'),
Loading history...
51
                ],
52
                'formio-config'
53
            );
54
55
            $this->publishes(
56
                [
57
                    __DIR__ . '/../../database/migrations' => database_path('migrations'),
0 ignored issues
show
Bug introduced by
The function database_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
                    __DIR__ . '/../../database/migrations' => /** @scrutinizer ignore-call */ database_path('migrations'),
Loading history...
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