1 | <?php namespace Arcanedev\LaravelSitemap\Helpers; |
||
15 | class SitemapGenerator implements SitemapGeneratorContract |
||
16 | { |
||
17 | /* ------------------------------------------------------------------------------------------------ |
||
18 | | Properties |
||
19 | | ------------------------------------------------------------------------------------------------ |
||
20 | */ |
||
21 | /** @var \Illuminate\Contracts\View\Factory */ |
||
22 | protected $view; |
||
23 | |||
24 | /** @var \Illuminate\Contracts\Cache\Repository */ |
||
25 | protected $cache; |
||
26 | |||
27 | /** @var \Arcanedev\LaravelSitemap\Contracts\SitemapStyler */ |
||
28 | protected $styler; |
||
29 | |||
30 | /** @var array */ |
||
31 | protected $contentTypes = [ |
||
32 | 'html' => 'text/html', |
||
33 | 'ror-rdf' => 'text/rdf+xml; charset=utf-8', |
||
34 | 'ror-rss' => 'text/rss+xml; charset=utf-8', |
||
35 | 'txt' => 'text/plain', |
||
36 | 'sitemapindex' => 'text/xml; charset=utf-8', |
||
37 | 'xml' => 'text/xml; charset=utf-8' |
||
38 | ]; |
||
39 | |||
40 | /* ------------------------------------------------------------------------------------------------ |
||
41 | | Constructor |
||
42 | | ------------------------------------------------------------------------------------------------ |
||
43 | */ |
||
44 | /** |
||
45 | * SitemapGenerator constructor. |
||
46 | * |
||
47 | * @param \Arcanedev\LaravelSitemap\Contracts\SitemapStyler $styler |
||
48 | * @param \Illuminate\Contracts\Cache\Repository $cache |
||
49 | * @param \Illuminate\Contracts\View\Factory $view |
||
50 | */ |
||
51 | 80 | public function __construct( |
|
60 | |||
61 | /* ------------------------------------------------------------------------------------------------ |
||
62 | | Getters & Setters |
||
63 | | ------------------------------------------------------------------------------------------------ |
||
64 | */ |
||
65 | /** |
||
66 | * Get the sitemap styles location. |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | 16 | public function getStylesLocation() |
|
74 | |||
75 | /** |
||
76 | * Set the sitemap styles location. |
||
77 | * |
||
78 | * @param string $location |
||
79 | * |
||
80 | * @return self |
||
81 | */ |
||
82 | 16 | public function setStylesLocation($location) |
|
88 | |||
89 | /** |
||
90 | * Set the use styles value. |
||
91 | * |
||
92 | * @param bool $useStyles |
||
93 | * |
||
94 | * @return self |
||
95 | */ |
||
96 | 16 | public function setUseStyles($useStyles) |
|
102 | |||
103 | /* ------------------------------------------------------------------------------------------------ |
||
104 | | Main Functions |
||
105 | | ------------------------------------------------------------------------------------------------ |
||
106 | */ |
||
107 | /** |
||
108 | * @param array $data |
||
109 | * @param string $format |
||
110 | * @param string|null $style |
||
111 | * |
||
112 | * @return array |
||
113 | */ |
||
114 | 8 | public function generate(array $data, $format = 'xml', $style = null) |
|
124 | |||
125 | /* ------------------------------------------------------------------------------------------------ |
||
126 | | Check Functions |
||
127 | | ------------------------------------------------------------------------------------------------ |
||
128 | */ |
||
129 | /** |
||
130 | * Check is styles is enabled. |
||
131 | * |
||
132 | * @return bool |
||
133 | */ |
||
134 | 16 | public function isStylesEnabled() |
|
138 | |||
139 | /* ------------------------------------------------------------------------------------------------ |
||
140 | | Other Functions |
||
141 | | ------------------------------------------------------------------------------------------------ |
||
142 | */ |
||
143 | /** |
||
144 | * Get the rendered content. |
||
145 | * |
||
146 | * @param array $data |
||
147 | * @param string $format |
||
148 | * |
||
149 | * @return string |
||
150 | */ |
||
151 | 8 | private function getContent(array $data, $format) |
|
157 | |||
158 | /** |
||
159 | * Get the headers. |
||
160 | * |
||
161 | * @param string $format |
||
162 | * |
||
163 | * @return array |
||
164 | */ |
||
165 | 8 | protected function getHeaders($format) |
|
171 | } |
||
172 |