Completed
Push — master ( 52dd7e...9d8639 )
by ARCANEDEV
11s
created

LaravelSitemapServiceProvider::getBasePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace Arcanedev\LaravelSitemap;
2
3
use Arcanedev\Support\PackageServiceProvider as ServiceProvider;
4
5
/**
6
 * Class     LaravelSitemapServiceProvider
7
 *
8
 * @package  Arcanedev\LaravelSitemap
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class LaravelSitemapServiceProvider extends ServiceProvider
12
{
13
    /* -----------------------------------------------------------------
14
     |  Properties
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * Package name.
20
     *
21
     * @var string
22
     */
23
    protected $package = 'sitemap';
24
25
    /**
26
     * Indicates if loading of the provider is deferred.
27
     *
28
     * @var bool
29
     */
30
    protected $defer   = true;
31
32
    /* -----------------------------------------------------------------
33
     |  Main Methods
34
     | -----------------------------------------------------------------
35
     */
36
37
    /**
38
     * Register the service provider.
39
     */
40 114
    public function register()
41
    {
42 114
        parent::register();
43
44 114
        $this->registerConfig();
45 114
        $this->registerSitemapStyler();
46 114
        $this->registerSitemapGenerator();
47 114
        $this->registerSitemapManager();
48 114
    }
49
50
    /**
51
     * Boot the service provider.
52
     */
53 114
    public function boot()
54
    {
55 114
        parent::boot();
56
57 114
        $this->publishConfig();
58 114
        $this->publishViews();
59 114
        $this->publishTranslations();
60
61 114
        $this->publishes([
62 114
            $this->getBasePath().'/public' => public_path(Helpers\SitemapStyler::VENDOR_PATH)
63 114
        ], 'public');
64 114
    }
65
66
    /**
67
     * Get the services provided by the provider.
68
     *
69
     * @return array
70
     */
71 6
    public function provides()
72
    {
73
        return [
74 6
            Contracts\SitemapManager::class,
75 2
            Contracts\SitemapStyler::class,
76 2
            Contracts\SitemapGenerator::class,
77 2
        ];
78
    }
79
80
    /* -----------------------------------------------------------------
81
     |  Other Methods
82
     | -----------------------------------------------------------------
83
     */
84
85
    /**
86
     * Register the sitemap styler.
87
     */
88 114
    private function registerSitemapStyler()
89
    {
90 114
        $this->bind(Contracts\SitemapStyler::class, Helpers\SitemapStyler::class);
91 114
    }
92
93
    /**
94
     * Register the sitemap generator.
95
     */
96 114
    private function registerSitemapGenerator()
97
    {
98 114
        $this->bind(Contracts\SitemapGenerator::class, Helpers\SitemapGenerator::class);
99 114
    }
100
101
    /**
102
     * Register the sitemap manager.
103
     */
104
    private function registerSitemapManager()
105
    {
106 114
        $this->app->bind(Contracts\SitemapManager::class, function ($app) {
107
            /**
108
             * @var  \Illuminate\Contracts\Config\Repository               $config
109
             * @var  \Illuminate\Contracts\Cache\Factory                   $cache
110
             * @var  \Illuminate\Filesystem\Filesystem                     $filesystem
111
             * @var  \Arcanedev\LaravelSitemap\Contracts\SitemapGenerator  $generator
112
             */
113 18
            $cache      = $app['cache'];
114 18
            $config     = $app['config'];
115 18
            $filesystem = $app['files'];
116 18
            $generator  = $app[Contracts\SitemapGenerator::class];
117
118 18
            return new SitemapManager(
119 18
                $cache->store(),
120 6
                $config,
121 6
                $filesystem,
122 12
                $generator
123 6
            );
124 114
        });
125 114
    }
126
}
127