/** * @return void */ public function prepareFavicon() { if ($this->pageConfig->getFaviconFile()) { $this->pageConfig->addRemotePageAsset($this->pageConfig->getFaviconFile(), Generator\Head::VIRTUAL_CONTENT_TYPE_LINK, ['attributes' => ['rel' => 'icon', 'type' => 'image/x-icon']], 'icon'); $this->pageConfig->addRemotePageAsset($this->pageConfig->getFaviconFile(), Generator\Head::VIRTUAL_CONTENT_TYPE_LINK, ['attributes' => ['rel' => 'shortcut icon', 'type' => 'image/x-icon']], 'shortcut-icon'); } else { $this->pageConfig->addPageAsset($this->pageConfig->getDefaultFavicon(), ['attributes' => ['rel' => 'icon', 'type' => 'image/x-icon']], 'icon'); $this->pageConfig->addPageAsset($this->pageConfig->getDefaultFavicon(), ['attributes' => ['rel' => 'shortcut icon', 'type' => 'image/x-icon']], 'shortcut-icon'); } }
/** * Add assets to page config * * @param \Magento\Framework\View\Page\Config\Structure $pageStructure * @return $this */ protected function processAssets(Structure $pageStructure) { foreach ($pageStructure->getAssets() as $name => $data) { if (isset($data['src_type']) && in_array($data['src_type'], $this->remoteAssetTypes)) { $this->pageConfig->addRemotePageAsset($name, self::VIRTUAL_CONTENT_TYPE_LINK, $this->getAssetProperties($data)); } else { $this->pageConfig->addPageAsset($name, $this->getAssetProperties($data)); } } return $this; }
/** * @param string $url * @param string $contentType * @param array $properties * @param string|null $name * @param string $expectedName * * @dataProvider remotePageAssetDataProvider */ public function testAddRemotePageAsset($url, $contentType, $properties, $name, $expectedName) { $this->assetRepo->expects($this->once())->method('createRemoteAsset')->with($url, $contentType)->will( $this->returnValue($this->remoteAsset) ); $this->pageAssets->expects($this->once())->method('add')->with($expectedName, $this->remoteAsset, $properties); $this->assertInstanceOf( 'Magento\Framework\View\Page\Config', $this->model->addRemotePageAsset($url, $contentType, $properties, $name) ); }
/** * {@inheritdoc} */ public function addRemotePageAsset($url, $contentType, array $properties = array(), $name = null) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'addRemotePageAsset'); if (!$pluginInfo) { return parent::addRemotePageAsset($url, $contentType, $properties, $name); } else { return $this->___callPlugins('addRemotePageAsset', func_get_args(), $pluginInfo); } }