/** * @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 $file * @param array $properties * @param string|null $name * @param string $expectedName * * @dataProvider pageAssetDataProvider */ public function testAddPageAsset($file, $properties, $name, $expectedName) { $this->assetRepo->expects($this->once())->method('createAsset')->with($file)->will( $this->returnValue($this->asset) ); $this->pageAssets->expects($this->once())->method('add')->with($expectedName, $this->asset, $properties); $this->assertInstanceOf( 'Magento\Framework\View\Page\Config', $this->model->addPageAsset($file, $properties, $name) ); }
/** * {@inheritdoc} */ public function addPageAsset($file, array $properties = array(), $name = null) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'addPageAsset'); if (!$pluginInfo) { return parent::addPageAsset($file, $properties, $name); } else { return $this->___callPlugins('addPageAsset', func_get_args(), $pluginInfo); } }