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 = '') |
||
87 | |||
88 | /** |
||
89 | * {@inheritdoc} |
||
90 | */ |
||
91 | public function setTitle($title) |
||
97 | |||
98 | /** |
||
99 | * {@inheritdoc} |
||
100 | */ |
||
101 | public function addTitle($title) |
||
107 | |||
108 | /** |
||
109 | * {@inheritdoc} |
||
110 | */ |
||
111 | public function getTitle() |
||
115 | |||
116 | /** |
||
117 | * {@inheritdoc} |
||
118 | */ |
||
119 | public function getMetas() |
||
123 | |||
124 | /** |
||
125 | * {@inheritdoc} |
||
126 | */ |
||
127 | public function addMeta($type, $name, $content, array $extras = []) |
||
137 | |||
138 | /** |
||
139 | * @param string $type |
||
140 | * @param string $name |
||
141 | * |
||
142 | * @return bool |
||
143 | */ |
||
144 | public function hasMeta($type, $name) |
||
148 | |||
149 | /** |
||
150 | * @param string $type |
||
151 | * @param string $name |
||
152 | * |
||
153 | * @return $this |
||
154 | */ |
||
155 | public function removeMeta($type, $name) |
||
161 | |||
162 | /** |
||
163 | * {@inheritdoc} |
||
164 | */ |
||
165 | public function setMetas(array $metadatas) |
||
183 | |||
184 | /** |
||
185 | * {@inheritdoc} |
||
186 | */ |
||
187 | public function setHtmlAttributes(array $attributes) |
||
193 | |||
194 | /** |
||
195 | * {@inheritdoc} |
||
196 | */ |
||
197 | public function addHtmlAttributes($name, $value) |
||
203 | |||
204 | /** |
||
205 | * @param string $name |
||
206 | * |
||
207 | * @return $this |
||
208 | */ |
||
209 | public function removeHtmlAttributes($name) |
||
215 | |||
216 | /** |
||
217 | * {@inheritdoc} |
||
218 | */ |
||
219 | public function getHtmlAttributes() |
||
223 | |||
224 | /** |
||
225 | * @param string $name |
||
226 | * |
||
227 | * @return bool |
||
228 | */ |
||
229 | public function hasHtmlAttribute($name) |
||
233 | |||
234 | /** |
||
235 | * @param array $attributes |
||
236 | * |
||
237 | * @return SeoPageInterface |
||
238 | */ |
||
239 | public function setHeadAttributes(array $attributes) |
||
245 | |||
246 | /** |
||
247 | * @param string $name |
||
248 | * @param string $value |
||
249 | * |
||
250 | * @return SeoPageInterface |
||
251 | */ |
||
252 | public function addHeadAttribute($name, $value) |
||
258 | |||
259 | /** |
||
260 | * @param string $name |
||
261 | * |
||
262 | * @return $this |
||
263 | */ |
||
264 | public function removeHeadAttribute($name) |
||
270 | |||
271 | /** |
||
272 | * @return array |
||
273 | */ |
||
274 | public function getHeadAttributes() |
||
278 | |||
279 | /** |
||
280 | * @param string $name |
||
281 | * |
||
282 | * @return array |
||
283 | */ |
||
284 | public function hasHeadAttribute($name) |
||
288 | |||
289 | /** |
||
290 | * {@inheritdoc} |
||
291 | */ |
||
292 | public function setLinkCanonical($link) |
||
298 | |||
299 | /** |
||
300 | * {@inheritdoc} |
||
301 | */ |
||
302 | public function getLinkCanonical() |
||
306 | |||
307 | /** |
||
308 | * {@inheritdoc} |
||
309 | */ |
||
310 | public function removeLinkCanonical() |
||
314 | |||
315 | /** |
||
316 | * {@inheritdoc} |
||
317 | */ |
||
318 | public function setSeparator($separator) |
||
324 | |||
325 | /** |
||
326 | * {@inheritdoc} |
||
327 | */ |
||
328 | public function setLangAlternates(array $langAlternates) |
||
334 | |||
335 | /** |
||
336 | * {@inheritdoc} |
||
337 | */ |
||
338 | public function addLangAlternate($href, $hrefLang) |
||
344 | |||
345 | /** |
||
346 | * @param string $href |
||
347 | * |
||
348 | * @return $this |
||
349 | */ |
||
350 | public function removeLangAlternate($href) |
||
356 | |||
357 | /** |
||
358 | * @param string $href |
||
359 | * |
||
360 | * @return $this |
||
361 | */ |
||
362 | public function hasLangAlternate($href) |
||
366 | |||
367 | /** |
||
368 | * {@inheritdoc} |
||
369 | */ |
||
370 | public function getLangAlternates() |
||
374 | |||
375 | /** |
||
376 | * @param $title |
||
377 | * @param $link |
||
378 | * |
||
379 | * @return SeoPageInterface |
||
380 | */ |
||
381 | public function addOEmbedLink($title, $link) |
||
387 | |||
388 | /** |
||
389 | * @return array |
||
390 | */ |
||
391 | public function getOEmbedLinks() |
||
395 | |||
396 | /** |
||
397 | * {@inheritdoc} |
||
398 | */ |
||
399 | public function getStructuredData() |
||
403 | |||
404 | /** |
||
405 | * {@inheritdoc} |
||
406 | */ |
||
407 | public function setStructuredData($structuredData) |
||
413 | |||
414 | /** |
||
415 | * @param mixed $meta |
||
416 | * |
||
417 | * @return array |
||
418 | */ |
||
419 | private function normalize($meta) |
||
427 | } |
||
428 |