MapperServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
namespace Cornford\Googlmapper;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class MapperServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Indicates if loading of the provider is deferred.
11
     *
12
     * @var bool
13
     */
14
    protected $defer = false;
15
16
    /**
17
     * Bootstrap the application events.
18
     *
19
     * @return void
20
     */
21
    public function boot()
22
    {
23
        $this->loadViewsFrom(base_path('resources/views/cornford/googlmapper'), 'googlmapper');
24
25
        $this->publishes(
26
            [
27
                __DIR__ . '/../config/config.php' => config_path('googlmapper.php'),
28
                __DIR__ . '/../resources/views' => base_path('resources/views/cornford/googlmapper')
29
            ],
30
            'googlmapper'
31
        );
32
33
        $this->app->alias(Mapper::class, 'mapper');
34
    }
35
36
    /**
37
     * Register the service provider.
38
     *
39
     * @return void
40
     */
41
    public function register()
42
    {
43
        $configPath = __DIR__ . '/../config/config.php';
44
        $this->mergeConfigFrom($configPath, 'googlmapper');
45
46
        $this->app->singleton(
47
            Mapper::class,
48
            function ($app) {
49
                return new Mapper($app->view, $app['config']->get('googlmapper'));
50
            }
51
        );
52
    }
53
54
    /**
55
     * Get the services provided by the provider.
56
     *
57
     * @return array
58
     */
59
    public function provides()
60
    {
61
        return ['mapper', Mapper::class];
62
    }
63
}
64