10
10
use Magento \Framework \View \Asset \GroupedCollection ;
11
11
use Magento \Framework \View \Page \Config ;
12
12
use Magento \Framework \View \Page \Config \Metadata \MsApplicationTileImage ;
13
+ use Psr \Log \LoggerInterface ;
14
+ use Magento \Framework \UrlInterface ;
15
+ use Magento \Framework \Escaper ;
16
+ use Magento \Framework \Stdlib \StringUtils ;
17
+ use Magento \Framework \View \Asset \MergeService ;
13
18
14
19
/**
15
20
* Page config Renderer model
@@ -51,29 +56,29 @@ class Renderer implements RendererInterface
51
56
protected $ pageConfig ;
52
57
53
58
/**
54
- * @var \Magento\Framework\View\Asset\ MergeService
59
+ * @var MergeService
55
60
*/
56
61
protected $ assetMergeService ;
57
62
58
63
/**
59
- * @var \Magento\Framework\Escaper
64
+ * @var UrlInterface
60
65
*/
61
- protected $ escaper ;
66
+ protected $ urlBuilder ;
62
67
63
68
/**
64
- * @var \Magento\Framework\Stdlib\StringUtils
69
+ * @var Escaper
65
70
*/
66
- protected $ string ;
71
+ protected $ escaper ;
67
72
68
73
/**
69
- * @var \Psr\Log\LoggerInterface
74
+ * @var StringUtils
70
75
*/
71
- protected $ logger ;
76
+ protected $ string ;
72
77
73
78
/**
74
- * @var \Magento\Framework\UrlInterface
79
+ * @var LoggerInterface
75
80
*/
76
- protected $ urlBuilder ;
81
+ protected $ logger ;
77
82
78
83
/**
79
84
* @var MsApplicationTileImage
@@ -82,20 +87,20 @@ class Renderer implements RendererInterface
82
87
83
88
/**
84
89
* @param Config $pageConfig
85
- * @param \Magento\Framework\View\Asset\ MergeService $assetMergeService
86
- * @param \Magento\Framework\ UrlInterface $urlBuilder
87
- * @param \Magento\Framework\ Escaper $escaper
88
- * @param \Magento\Framework\Stdlib\ StringUtils $string
89
- * @param \Psr\Log\ LoggerInterface $logger
90
+ * @param MergeService $assetMergeService
91
+ * @param UrlInterface $urlBuilder
92
+ * @param Escaper $escaper
93
+ * @param StringUtils $string
94
+ * @param LoggerInterface $logger
90
95
* @param MsApplicationTileImage|null $msApplicationTileImage
91
96
*/
92
97
public function __construct (
93
98
Config $ pageConfig ,
94
- \ Magento \ Framework \ View \ Asset \ MergeService $ assetMergeService ,
95
- \ Magento \ Framework \ UrlInterface $ urlBuilder ,
96
- \ Magento \ Framework \ Escaper $ escaper ,
97
- \ Magento \ Framework \ Stdlib \ StringUtils $ string ,
98
- \ Psr \ Log \ LoggerInterface $ logger ,
99
+ MergeService $ assetMergeService ,
100
+ UrlInterface $ urlBuilder ,
101
+ Escaper $ escaper ,
102
+ StringUtils $ string ,
103
+ LoggerInterface $ logger ,
99
104
MsApplicationTileImage $ msApplicationTileImage = null
100
105
) {
101
106
$ this ->pageConfig = $ pageConfig ;
@@ -149,6 +154,7 @@ public function renderHeadAssets()
149
154
$ result .= $ this ->pageConfig ->getIncludes ();
150
155
return $ result ;
151
156
}
157
+
152
158
/**
153
159
* Render title
154
160
*
@@ -220,26 +226,20 @@ protected function getMetadataTemplate($name)
220
226
221
227
switch ($ name ) {
222
228
case Config::META_CHARSET :
223
- $ metadataTemplate = '<meta charset="%content"/> ' . "\n" ;
224
- break ;
229
+ return '<meta charset="%content"/> ' . "\n" ;
225
230
226
231
case Config::META_CONTENT_TYPE :
227
- $ metadataTemplate = '<meta http-equiv="Content-Type" content="%content"/> ' . "\n" ;
228
- break ;
232
+ return '<meta http-equiv="Content-Type" content="%content"/> ' . "\n" ;
229
233
230
234
case Config::META_X_UI_COMPATIBLE :
231
- $ metadataTemplate = '<meta http-equiv="X-UA-Compatible" content="%content"/> ' . "\n" ;
232
- break ;
235
+ return '<meta http-equiv="X-UA-Compatible" content="%content"/> ' . "\n" ;
233
236
234
237
case Config::META_MEDIA_TYPE :
235
- $ metadataTemplate = false ;
236
- break ;
238
+ return false ;
237
239
238
240
default :
239
- $ metadataTemplate = '<meta name="%name" content="%content"/> ' . "\n" ;
240
- break ;
241
+ return '<meta name="%name" content="%content"/> ' . "\n" ;
241
242
}
242
- return $ metadataTemplate ;
243
243
}
244
244
245
245
/**
@@ -250,32 +250,47 @@ protected function getMetadataTemplate($name)
250
250
public function prepareFavicon ()
251
251
{
252
252
if ($ this ->pageConfig ->getFaviconFile ()) {
253
- $ this ->pageConfig -> addRemotePageAsset (
253
+ $ this ->addFaviconAsset (
254
254
$ this ->pageConfig ->getFaviconFile (),
255
- Generator \Head::VIRTUAL_CONTENT_TYPE_LINK ,
256
255
['attributes ' => ['rel ' => 'icon ' , 'type ' => 'image/x-icon ' ]],
257
256
'icon '
258
257
);
259
- $ this ->pageConfig -> addRemotePageAsset (
258
+ $ this ->addFaviconAsset (
260
259
$ this ->pageConfig ->getFaviconFile (),
261
- Generator \Head::VIRTUAL_CONTENT_TYPE_LINK ,
262
260
['attributes ' => ['rel ' => 'shortcut icon ' , 'type ' => 'image/x-icon ' ]],
263
261
'shortcut-icon '
264
262
);
265
263
} else {
266
- $ this ->pageConfig -> addPageAsset (
264
+ $ this ->addFaviconAsset (
267
265
$ this ->pageConfig ->getDefaultFavicon (),
268
266
['attributes ' => ['rel ' => 'icon ' , 'type ' => 'image/x-icon ' ]],
269
267
'icon '
270
268
);
271
- $ this ->pageConfig -> addPageAsset (
269
+ $ this ->addFaviconAsset (
272
270
$ this ->pageConfig ->getDefaultFavicon (),
273
271
['attributes ' => ['rel ' => 'shortcut icon ' , 'type ' => 'image/x-icon ' ]],
274
272
'shortcut-icon '
275
273
);
276
274
}
277
275
}
278
276
277
+ /**
278
+ * Add favicon asset
279
+ *
280
+ * @param string $file
281
+ * @param array $attributes
282
+ * @param string $name
283
+ */
284
+ protected function addFaviconAsset ($ file , $ attributes , $ name )
285
+ {
286
+ $ this ->pageConfig ->addRemotePageAsset (
287
+ $ file ,
288
+ Generator \Head::VIRTUAL_CONTENT_TYPE_LINK ,
289
+ $ attributes ,
290
+ $ name
291
+ );
292
+ }
293
+
279
294
/**
280
295
* Returns rendered HTML for all Assets (CSS before)
281
296
*
0 commit comments