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
|
|
|
* Package name. |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $package = 'sitemap'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Indicates if loading of the provider is deferred. |
26
|
|
|
* |
27
|
|
|
* @var bool |
28
|
|
|
*/ |
29
|
|
|
protected $defer = true; |
30
|
|
|
|
31
|
|
|
/* ------------------------------------------------------------------------------------------------ |
32
|
|
|
| Getters & Setters |
33
|
|
|
| ------------------------------------------------------------------------------------------------ |
34
|
|
|
*/ |
35
|
|
|
/** |
36
|
|
|
* Get the base path of the package. |
37
|
|
|
* |
38
|
|
|
* @return string |
39
|
|
|
*/ |
40
|
256 |
|
public function getBasePath() |
41
|
|
|
{ |
42
|
256 |
|
return dirname(__DIR__); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/* ------------------------------------------------------------------------------------------------ |
46
|
|
|
| Main Functions |
47
|
|
|
| ------------------------------------------------------------------------------------------------ |
48
|
|
|
*/ |
49
|
|
|
/** |
50
|
|
|
* Register the service provider. |
51
|
|
|
*/ |
52
|
256 |
|
public function register() |
53
|
|
|
{ |
54
|
256 |
|
$this->registerConfig(); |
55
|
256 |
|
$this->registerSitemapStyler(); |
56
|
256 |
|
$this->registerSitemapManager(); |
57
|
256 |
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Boot the service provider. |
61
|
|
|
*/ |
62
|
256 |
|
public function boot() |
63
|
|
|
{ |
64
|
256 |
|
$this->publishConfig(); |
65
|
256 |
|
$this->publishViews(); |
66
|
256 |
|
$this->publishTranslations(); |
67
|
|
|
|
68
|
256 |
|
$this->publishes([ |
69
|
256 |
|
$this->getBasePath() . '/public' => public_path(Helpers\SitemapStyler::VENDOR_PATH) |
70
|
256 |
|
], 'public'); |
71
|
256 |
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Get the services provided by the provider. |
75
|
|
|
* |
76
|
|
|
* @return array |
77
|
|
|
*/ |
78
|
16 |
|
public function provides() |
79
|
|
|
{ |
80
|
|
|
return [ |
81
|
16 |
|
'sitemap.manager', |
82
|
12 |
|
Contracts\SitemapManager::class, |
83
|
12 |
|
'sitemap.styler', |
84
|
12 |
|
Contracts\SitemapStyler::class, |
85
|
12 |
|
]; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/* ------------------------------------------------------------------------------------------------ |
89
|
|
|
| Other Functions |
90
|
|
|
| ------------------------------------------------------------------------------------------------ |
91
|
|
|
*/ |
92
|
|
|
/** |
93
|
|
|
* Register the sitemap manager. |
94
|
|
|
*/ |
95
|
|
|
private function registerSitemapManager() |
96
|
|
|
{ |
97
|
256 |
|
$this->app->bind('sitemap.manager', function ($app) { |
98
|
|
|
/** |
99
|
|
|
* @var \Illuminate\Contracts\Config\Repository $config |
100
|
|
|
* @var \Illuminate\Cache\CacheManager $cache |
101
|
|
|
* @var \Illuminate\Filesystem\Filesystem $filesystem |
102
|
|
|
* @var \Arcanedev\LaravelSitemap\Contracts\SitemapStyler $styler |
103
|
|
|
*/ |
104
|
32 |
|
$cache = $app['cache']; |
105
|
32 |
|
$config = $app['config']; |
106
|
32 |
|
$filesystem = $app['files']; |
107
|
32 |
|
$styler = $app['sitemap.styler']; |
108
|
|
|
|
109
|
32 |
|
return new SitemapManager($cache->driver(), $config, $filesystem, $styler); |
110
|
256 |
|
}); |
111
|
256 |
|
$this->bind(Contracts\SitemapManager::class, 'sitemap.manager'); |
112
|
256 |
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Register the sitemap styler. |
116
|
|
|
*/ |
117
|
256 |
|
private function registerSitemapStyler() |
118
|
|
|
{ |
119
|
256 |
|
$this->app->bind('sitemap.styler', Helpers\SitemapStyler::class); |
120
|
256 |
|
$this->bind(Contracts\SitemapStyler::class, 'sitemap.styler'); |
121
|
256 |
|
} |
122
|
|
|
} |
123
|
|
|
|