1 | <?php |
||
17 | class SeoPage implements SeoPageInterface, StructuredDataAwarePage |
||
18 | { |
||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $title; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $metas; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $htmlAttributes; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $linkCanonical; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $separator; |
||
43 | |||
44 | /** |
||
45 | * @var array |
||
46 | */ |
||
47 | protected $headAttributes; |
||
48 | |||
49 | /** |
||
50 | * @var array |
||
51 | */ |
||
52 | protected $langAlternates; |
||
53 | |||
54 | /** |
||
55 | * @var array |
||
56 | */ |
||
57 | protected $oembedLinks; |
||
58 | |||
59 | /** |
||
60 | * A JSON-LD string, which can be served as structured data. |
||
61 | * |
||
62 | * @var string |
||
63 | */ |
||
64 | private $structuredData; |
||
65 | |||
66 | /** |
||
67 | * @param string $title |
||
68 | */ |
||
69 | public function __construct($title = '') |
||
88 | |||
89 | /** |
||
90 | * {@inheritdoc} |
||
91 | */ |
||
92 | public function setTitle($title) |
||
98 | |||
99 | /** |
||
100 | * {@inheritdoc} |
||
101 | */ |
||
102 | public function addTitle($title) |
||
108 | |||
109 | /** |
||
110 | * {@inheritdoc} |
||
111 | */ |
||
112 | public function getTitle() |
||
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | public function getMetas() |
||
124 | |||
125 | /** |
||
126 | * {@inheritdoc} |
||
127 | */ |
||
128 | public function addMeta($type, $name, $content, array $extras = []) |
||
138 | |||
139 | /** |
||
140 | * @param string $type |
||
141 | * @param string $name |
||
142 | * |
||
143 | * @return bool |
||
144 | */ |
||
145 | public function hasMeta($type, $name) |
||
149 | |||
150 | /** |
||
151 | * @param string $type |
||
152 | * @param string $name |
||
153 | * |
||
154 | * @return $this |
||
155 | */ |
||
156 | public function removeMeta($type, $name) |
||
162 | |||
163 | /** |
||
164 | * {@inheritdoc} |
||
165 | */ |
||
166 | public function setMetas(array $metadatas) |
||
184 | |||
185 | /** |
||
186 | * {@inheritdoc} |
||
187 | */ |
||
188 | public function setHtmlAttributes(array $attributes) |
||
194 | |||
195 | /** |
||
196 | * {@inheritdoc} |
||
197 | */ |
||
198 | public function addHtmlAttributes($name, $value) |
||
204 | |||
205 | /** |
||
206 | * @param string $name |
||
207 | * |
||
208 | * @return $this |
||
209 | */ |
||
210 | public function removeHtmlAttributes($name) |
||
216 | |||
217 | /** |
||
218 | * {@inheritdoc} |
||
219 | */ |
||
220 | public function getHtmlAttributes() |
||
224 | |||
225 | /** |
||
226 | * @param string $name |
||
227 | * |
||
228 | * @return bool |
||
229 | */ |
||
230 | public function hasHtmlAttribute($name) |
||
234 | |||
235 | /** |
||
236 | * @param array $attributes |
||
237 | * |
||
238 | * @return SeoPageInterface |
||
239 | */ |
||
240 | public function setHeadAttributes(array $attributes) |
||
246 | |||
247 | /** |
||
248 | * @param string $name |
||
249 | * @param string $value |
||
250 | * |
||
251 | * @return SeoPageInterface |
||
252 | */ |
||
253 | public function addHeadAttribute($name, $value) |
||
259 | |||
260 | /** |
||
261 | * @param string $name |
||
262 | * |
||
263 | * @return $this |
||
264 | */ |
||
265 | public function removeHeadAttribute($name) |
||
271 | |||
272 | /** |
||
273 | * @return array |
||
274 | */ |
||
275 | public function getHeadAttributes() |
||
279 | |||
280 | /** |
||
281 | * @param string $name |
||
282 | * |
||
283 | * @return array |
||
284 | */ |
||
285 | public function hasHeadAttribute($name) |
||
289 | |||
290 | /** |
||
291 | * {@inheritdoc} |
||
292 | */ |
||
293 | public function setLinkCanonical($link) |
||
299 | |||
300 | /** |
||
301 | * {@inheritdoc} |
||
302 | */ |
||
303 | public function getLinkCanonical() |
||
307 | |||
308 | /** |
||
309 | * {@inheritdoc} |
||
310 | */ |
||
311 | public function removeLinkCanonical() |
||
315 | |||
316 | /** |
||
317 | * {@inheritdoc} |
||
318 | */ |
||
319 | public function setSeparator($separator) |
||
325 | |||
326 | /** |
||
327 | * {@inheritdoc} |
||
328 | */ |
||
329 | public function setLangAlternates(array $langAlternates) |
||
335 | |||
336 | /** |
||
337 | * {@inheritdoc} |
||
338 | */ |
||
339 | public function addLangAlternate($href, $hrefLang) |
||
345 | |||
346 | /** |
||
347 | * @param string $href |
||
348 | * |
||
349 | * @return $this |
||
350 | */ |
||
351 | public function removeLangAlternate($href) |
||
357 | |||
358 | /** |
||
359 | * @param string $href |
||
360 | * |
||
361 | * @return $this |
||
362 | */ |
||
363 | public function hasLangAlternate($href) |
||
367 | |||
368 | /** |
||
369 | * {@inheritdoc} |
||
370 | */ |
||
371 | public function getLangAlternates() |
||
375 | |||
376 | /** |
||
377 | * @param $title |
||
378 | * @param $link |
||
379 | * |
||
380 | * @return SeoPageInterface |
||
381 | */ |
||
382 | public function addOEmbedLink($title, $link) |
||
388 | |||
389 | /** |
||
390 | * @return array |
||
391 | */ |
||
392 | public function getOEmbedLinks() |
||
396 | |||
397 | public function getStructuredData() |
||
401 | |||
402 | public function setStructuredData($structuredData) |
||
408 | |||
409 | /** |
||
410 | * @param mixed $meta |
||
411 | * |
||
412 | * @return array |
||
413 | */ |
||
414 | private function normalize($meta) |
||
422 | } |
||
423 |