Completed
Push — master ( 335da2...6aa3b5 )
by Marcel
10s
created

ApiDocGeneratorServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Mpociot\ApiDoc;
4
5
use Illuminate\Support\ServiceProvider;
6
use Mpociot\ApiDoc\Commands\UpdateDocumentation;
7
use Mpociot\ApiDoc\Commands\GenerateDocumentation;
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
        $this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'apidoc');
20
21
        $this->publishes([
22
            __DIR__.'/../../resources/lang' => $this->resource_path('lang/vendor/apidoc'),
23
        ]);
24
    }
25
26
    /**
27
     * Register the API doc commands.
28
     *
29
     * @return void
30
     */
31
    public function register()
32
    {
33
        $this->app['apidoc.generate'] = $this->app->share(function () {
34
            return new GenerateDocumentation();
35
        });
36
        $this->app['apidoc.update'] = $this->app->share(function () {
37
            return new UpdateDocumentation();
38
        });
39
40
        $this->commands([
41
            'apidoc.generate',
42
            'apidoc.update',
43
        ]);
44
    }
45
46
    /**
47
     * Return a fully qualified path to a given file.
48
     *
49
     * @param string $path
50
     *
51
     * @return string
52
     */
53
    public function resource_path($path = '')
54
    {
55
        return app()->basePath().'/resources'.($path ? '/'.$path : $path);
56
    }
57
}
58