7
7
namespace Magento \Framework \View \Page ;
8
8
9
9
use Magento \Framework \App ;
10
- use Magento \Framework \Exception \ LocalizedException ;
10
+ use Magento \Framework \App \ Area ;
11
11
use Magento \Framework \View ;
12
12
13
13
/**
@@ -42,6 +42,7 @@ class Config
42
42
const META_TITLE = 'title ' ;
43
43
const META_KEYWORDS = 'keywords ' ;
44
44
const META_ROBOTS = 'robots ' ;
45
+ const META_X_UI_COMPATIBLE = 'x_ua_compatible ' ;
45
46
46
47
/**
47
48
* Constant body attribute class
@@ -253,7 +254,7 @@ public function getMetadata()
253
254
*/
254
255
public function setContentType ($ contentType )
255
256
{
256
- $ this ->setMetadata (' content_type ' , $ contentType );
257
+ $ this ->setMetadata (self :: META_CONTENT_TYPE , $ contentType );
257
258
}
258
259
259
260
/**
@@ -264,10 +265,10 @@ public function setContentType($contentType)
264
265
public function getContentType ()
265
266
{
266
267
$ this ->build ();
267
- if (strtolower ($ this ->metadata [' content_type ' ]) === 'auto ' ) {
268
- $ this ->metadata [' content_type ' ] = $ this ->getMediaType () . '; charset= ' . $ this ->getCharset ();
268
+ if (strtolower ($ this ->metadata [self :: META_CONTENT_TYPE ]) === 'auto ' ) {
269
+ $ this ->metadata [self :: META_CONTENT_TYPE ] = $ this ->getMediaType () . '; charset= ' . $ this ->getCharset ();
269
270
}
270
- return $ this ->metadata [' content_type ' ];
271
+ return $ this ->metadata [self :: META_CONTENT_TYPE ];
271
272
}
272
273
273
274
/**
@@ -276,7 +277,7 @@ public function getContentType()
276
277
*/
277
278
public function setMediaType ($ mediaType )
278
279
{
279
- $ this ->setMetadata (' media_type ' , $ mediaType );
280
+ $ this ->setMetadata (self :: META_MEDIA_TYPE , $ mediaType );
280
281
}
281
282
282
283
/**
@@ -287,13 +288,13 @@ public function setMediaType($mediaType)
287
288
public function getMediaType ()
288
289
{
289
290
$ this ->build ();
290
- if (empty ($ this ->metadata [' media_type ' ])) {
291
- $ this ->metadata [' media_type ' ] = $ this ->scopeConfig ->getValue (
291
+ if (empty ($ this ->metadata [self :: META_MEDIA_TYPE ])) {
292
+ $ this ->metadata [self :: META_MEDIA_TYPE ] = $ this ->scopeConfig ->getValue (
292
293
'design/head/default_media_type ' ,
293
294
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
294
295
);
295
296
}
296
- return $ this ->metadata [' media_type ' ];
297
+ return $ this ->metadata [self :: META_MEDIA_TYPE ];
297
298
}
298
299
299
300
/**
@@ -302,7 +303,7 @@ public function getMediaType()
302
303
*/
303
304
public function setCharset ($ charset )
304
305
{
305
- $ this ->setMetadata (' charset ' , $ charset );
306
+ $ this ->setMetadata (self :: META_CHARSET , $ charset );
306
307
}
307
308
308
309
/**
@@ -313,13 +314,13 @@ public function setCharset($charset)
313
314
public function getCharset ()
314
315
{
315
316
$ this ->build ();
316
- if (empty ($ this ->metadata [' charset ' ])) {
317
- $ this ->metadata [' charset ' ] = $ this ->scopeConfig ->getValue (
317
+ if (empty ($ this ->metadata [self :: META_CHARSET ])) {
318
+ $ this ->metadata [self :: META_CHARSET ] = $ this ->scopeConfig ->getValue (
318
319
'design/head/default_charset ' ,
319
320
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
320
321
);
321
322
}
322
- return $ this ->metadata [' charset ' ];
323
+ return $ this ->metadata [self :: META_CHARSET ];
323
324
}
324
325
325
326
/**
@@ -328,7 +329,7 @@ public function getCharset()
328
329
*/
329
330
public function setDescription ($ description )
330
331
{
331
- $ this ->setMetadata (' description ' , $ description );
332
+ $ this ->setMetadata (self :: META_DESCRIPTION , $ description );
332
333
}
333
334
334
335
/**
@@ -339,49 +340,21 @@ public function setDescription($description)
339
340
public function getDescription ()
340
341
{
341
342
$ this ->build ();
342
- if (empty ($ this ->metadata [' description ' ])) {
343
- $ this ->metadata [' description ' ] = $ this ->scopeConfig ->getValue (
343
+ if (empty ($ this ->metadata [self :: META_DESCRIPTION ])) {
344
+ $ this ->metadata [self :: META_DESCRIPTION ] = $ this ->scopeConfig ->getValue (
344
345
'design/head/default_description ' ,
345
346
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
346
347
);
347
348
}
348
- return $ this ->metadata ['description ' ];
349
- }
350
-
351
- /**
352
- * Get rendered metadata
353
- * @param string $fieldName
354
- * @return string
355
- * @throws LocalizedException
356
- */
357
- public function getRenderedMetaTagValue (string $ fieldName )
358
- {
359
- switch ($ fieldName ) {
360
- case self ::META_DESCRIPTION :
361
- return $ this ->getDescription ();
362
- case self ::META_CONTENT_TYPE :
363
- return $ this ->getContentType ();
364
- case self ::META_MEDIA_TYPE :
365
- return $ this ->getMediaType ();
366
- case self ::META_CHARSET :
367
- return $ this ->getCharset ();
368
- case self ::META_KEYWORDS :
369
- return $ this ->getKeywords ();
370
- case self ::META_ROBOTS :
371
- return $ this ->getRobots ();
372
- case self ::META_TITLE :
373
- return $ this ->getMetaTitle ();
374
- default :
375
- throw new LocalizedException (__ ('No rendered meta function for %1 ' , $ fieldName ));
376
- }
349
+ return $ this ->metadata [self ::META_DESCRIPTION ];
377
350
}
378
351
379
352
/**
380
353
* @param string $title
381
354
*/
382
355
public function setMetaTitle ($ title )
383
356
{
384
- $ this ->setMetadata (' title ' , $ title );
357
+ $ this ->setMetadata (self :: META_TITLE , $ title );
385
358
}
386
359
387
360
/**
@@ -392,11 +365,11 @@ public function setMetaTitle($title)
392
365
public function getMetaTitle ()
393
366
{
394
367
$ this ->build ();
395
- if (empty ($ this ->metadata [' title ' ])) {
368
+ if (empty ($ this ->metadata [self :: META_TITLE ])) {
396
369
return '' ;
397
370
}
398
371
399
- return $ this ->metadata [' title ' ];
372
+ return $ this ->metadata [self :: META_TITLE ];
400
373
}
401
374
402
375
/**
@@ -405,7 +378,7 @@ public function getMetaTitle()
405
378
*/
406
379
public function setKeywords ($ keywords )
407
380
{
408
- $ this ->setMetadata (' keywords ' , $ keywords );
381
+ $ this ->setMetadata (self :: META_KEYWORDS , $ keywords );
409
382
}
410
383
411
384
/**
@@ -416,13 +389,13 @@ public function setKeywords($keywords)
416
389
public function getKeywords ()
417
390
{
418
391
$ this ->build ();
419
- if (empty ($ this ->metadata [' keywords ' ])) {
420
- $ this ->metadata [' keywords ' ] = $ this ->scopeConfig ->getValue (
392
+ if (empty ($ this ->metadata [self :: META_KEYWORDS ])) {
393
+ $ this ->metadata [self :: META_KEYWORDS ] = $ this ->scopeConfig ->getValue (
421
394
'design/head/default_keywords ' ,
422
395
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
423
396
);
424
397
}
425
- return $ this ->metadata [' keywords ' ];
398
+ return $ this ->metadata [self :: META_KEYWORDS ];
426
399
}
427
400
428
401
/**
@@ -431,27 +404,28 @@ public function getKeywords()
431
404
*/
432
405
public function setRobots ($ robots )
433
406
{
434
- $ this ->setMetadata (' robots ' , $ robots );
407
+ $ this ->setMetadata (self :: META_ROBOTS , $ robots );
435
408
}
436
409
437
410
/**
438
411
* Retrieve URL to robots file
439
412
*
440
413
* @return string
414
+ * @throws \Magento\Framework\Exception\LocalizedException
441
415
*/
442
416
public function getRobots ()
443
417
{
444
- if ($ this ->getAreaResolver ()->getAreaCode () !== ' frontend ' ) {
418
+ if ($ this ->getAreaResolver ()->getAreaCode () !== Area:: AREA_FRONTEND ) {
445
419
return 'NOINDEX,NOFOLLOW ' ;
446
420
}
447
421
$ this ->build ();
448
- if (empty ($ this ->metadata [' robots ' ])) {
449
- $ this ->metadata [' robots ' ] = $ this ->scopeConfig ->getValue (
422
+ if (empty ($ this ->metadata [self :: META_ROBOTS ])) {
423
+ $ this ->metadata [self :: META_ROBOTS ] = $ this ->scopeConfig ->getValue (
450
424
'design/search_engine_robots/default_robots ' ,
451
425
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
452
426
);
453
427
}
454
- return $ this ->metadata [' robots ' ];
428
+ return $ this ->metadata [self :: META_ROBOTS ];
455
429
}
456
430
457
431
/**
0 commit comments