1010use Magento \Framework \View \Asset \GroupedCollection ;
1111use Magento \Framework \View \Page \Config ;
1212use 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 ;
1318
1419/**
1520 * Page config Renderer model
@@ -51,29 +56,29 @@ class Renderer implements RendererInterface
5156 protected $ pageConfig ;
5257
5358 /**
54- * @var \Magento\Framework\View\Asset\ MergeService
59+ * @var MergeService
5560 */
5661 protected $ assetMergeService ;
5762
5863 /**
59- * @var \Magento\Framework\Escaper
64+ * @var UrlInterface
6065 */
61- protected $ escaper ;
66+ protected $ urlBuilder ;
6267
6368 /**
64- * @var \Magento\Framework\Stdlib\StringUtils
69+ * @var Escaper
6570 */
66- protected $ string ;
71+ protected $ escaper ;
6772
6873 /**
69- * @var \Psr\Log\LoggerInterface
74+ * @var StringUtils
7075 */
71- protected $ logger ;
76+ protected $ string ;
7277
7378 /**
74- * @var \Magento\Framework\UrlInterface
79+ * @var LoggerInterface
7580 */
76- protected $ urlBuilder ;
81+ protected $ logger ;
7782
7883 /**
7984 * @var MsApplicationTileImage
@@ -82,20 +87,20 @@ class Renderer implements RendererInterface
8287
8388 /**
8489 * @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
9095 * @param MsApplicationTileImage|null $msApplicationTileImage
9196 */
9297 public function __construct (
9398 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 ,
99104 MsApplicationTileImage $ msApplicationTileImage = null
100105 ) {
101106 $ this ->pageConfig = $ pageConfig ;
@@ -149,6 +154,7 @@ public function renderHeadAssets()
149154 $ result .= $ this ->pageConfig ->getIncludes ();
150155 return $ result ;
151156 }
157+
152158 /**
153159 * Render title
154160 *
@@ -220,26 +226,20 @@ protected function getMetadataTemplate($name)
220226
221227 switch ($ name ) {
222228 case Config::META_CHARSET :
223- $ metadataTemplate = '<meta charset="%content"/> ' . "\n" ;
224- break ;
229+ return '<meta charset="%content"/> ' . "\n" ;
225230
226231 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" ;
229233
230234 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" ;
233236
234237 case Config::META_MEDIA_TYPE :
235- $ metadataTemplate = false ;
236- break ;
238+ return false ;
237239
238240 default :
239- $ metadataTemplate = '<meta name="%name" content="%content"/> ' . "\n" ;
240- break ;
241+ return '<meta name="%name" content="%content"/> ' . "\n" ;
241242 }
242- return $ metadataTemplate ;
243243 }
244244
245245 /**
@@ -250,32 +250,47 @@ protected function getMetadataTemplate($name)
250250 public function prepareFavicon ()
251251 {
252252 if ($ this ->pageConfig ->getFaviconFile ()) {
253- $ this ->pageConfig -> addRemotePageAsset (
253+ $ this ->addFaviconAsset (
254254 $ this ->pageConfig ->getFaviconFile (),
255- Generator \Head::VIRTUAL_CONTENT_TYPE_LINK ,
256255 ['attributes ' => ['rel ' => 'icon ' , 'type ' => 'image/x-icon ' ]],
257256 'icon '
258257 );
259- $ this ->pageConfig -> addRemotePageAsset (
258+ $ this ->addFaviconAsset (
260259 $ this ->pageConfig ->getFaviconFile (),
261- Generator \Head::VIRTUAL_CONTENT_TYPE_LINK ,
262260 ['attributes ' => ['rel ' => 'shortcut icon ' , 'type ' => 'image/x-icon ' ]],
263261 'shortcut-icon '
264262 );
265263 } else {
266- $ this ->pageConfig -> addPageAsset (
264+ $ this ->addFaviconAsset (
267265 $ this ->pageConfig ->getDefaultFavicon (),
268266 ['attributes ' => ['rel ' => 'icon ' , 'type ' => 'image/x-icon ' ]],
269267 'icon '
270268 );
271- $ this ->pageConfig -> addPageAsset (
269+ $ this ->addFaviconAsset (
272270 $ this ->pageConfig ->getDefaultFavicon (),
273271 ['attributes ' => ['rel ' => 'shortcut icon ' , 'type ' => 'image/x-icon ' ]],
274272 'shortcut-icon '
275273 );
276274 }
277275 }
278276
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+
279294 /**
280295 * Returns rendered HTML for all Assets (CSS before)
281296 *
0 commit comments