SSOServiceProvider::getConfigPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Zefy\LaravelSSO;
4
5
use Illuminate\Support\ServiceProvider;
6
use Zefy\LaravelSSO\Commands;
7
8
class SSOServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Configuration file name.
12
     *
13
     * @var string
14
     */
15
    protected $configFileName = 'laravel-sso.php';
16
17
    /**
18
     * Bootstrap services.
19
     *
20
     * @return void
21
     */
22
    public function boot()
23
    {
24
        $this->publishConfig(__DIR__ . '/../config/' . $this->configFileName);
25
26
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
27
28
        if ($this->app->runningInConsole()) {
29
            $this->commands([
30
                Commands\CreateBroker::class,
31
                Commands\DeleteBroker::class,
32
                Commands\ListBrokers::class,
33
            ]);
34
        }
35
36
        $this->loadRoutes();
37
    }
38
39
    /**
40
     * Register services.
41
     *
42
     * @return void
43
     */
44
    public function register()
45
    {
46
        $this->app->make('Zefy\LaravelSSO\Controllers\ServerController');
47
    }
48
49
    /**
50
     * Get the config path
51
     *
52
     * @return string
53
     */
54
    protected function getConfigPath()
55
    {
56
        return config_path($this->configFileName);
57
    }
58
59
    /**
60
     * Publish the config file
61
     *
62
     * @param string $configPath
63
     */
64
    protected function publishConfig(string $configPath)
65
    {
66
        $this->publishes([$configPath => $this->getConfigPath()]);
67
    }
68
69
    /**
70
     * Load necessary routes.
71
     *
72
     * @return void
73
     */
74
    protected function loadRoutes()
75
    {
76
        // If this page is server, load routes which is required for the server.
77
        if (config('laravel-sso.type') == 'server') {
78
            $this->loadRoutesFrom(__DIR__.'/Routes/server.php');
79
        }
80
    }
81
}
82