Completed
Pull Request — master (#659)
by Andrey
01:44
created

ApiDocGeneratorServiceProvider::bootRoutes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Mpociot\ApiDoc;
4
5
use Illuminate\Support\ServiceProvider;
6
use Mpociot\ApiDoc\Commands\GenerateDocumentation;
7
use Mpociot\ApiDoc\Commands\RebuildDocumentation;
8
9
class ApiDocGeneratorServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application events.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        $this->loadViewsFrom(__DIR__.'/../resources/views/', 'apidoc');
19
20
        $this->publishes([
21
            __DIR__.'/../resources/views' => app()->basePath().'/resources/views/vendor/apidoc',
22
        ], 'apidoc-views');
23
24
        $this->publishes([
25
            __DIR__.'/../config/apidoc.php' => app()->basePath().'/config/apidoc.php',
26
        ], 'apidoc-config');
27
28
        $this->mergeConfigFrom(__DIR__.'/../config/apidoc.php', 'apidoc');
29
30
        $this->bootRoutes();
31
32
        if ($this->app->runningInConsole()) {
33
            $this->commands([
34
                GenerateDocumentation::class,
35
                RebuildDocumentation::class,
36
            ]);
37
        }
38
    }
39
40
    /**
41
     * Register the API doc commands.
42
     *
43
     * @return void
44
     */
45
    public function register()
46
    {
47
        //
48
    }
49
50
    protected function bootRoutes()
51
    {
52
        if ($this->app['config']->get('apidoc.type', 'static') == 'laravel') {
53
            $this->loadRoutesFrom(
54
                __DIR__.'/../routes/laravel.php'
55
            );
56
        }
57
    }
58
}
59