/** * Save customized DOM of view configuration * * @param \DOMDocument $config * @return $this */ protected function _saveViewConfiguration(\DOMDocument $config) { $targetPath = $this->_theme->getCustomization()->getCustomViewConfigPath(); $directory = $this->_filesystem->getDirectoryWrite(DirectoryList::ROOT); $directory->writeFile($directory->getRelativePath($targetPath), $config->saveXML()); return $this; }
/** * Apply customized static files to frontend * * @param \Magento\Framework\Event\Observer $observer * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function execute(\Magento\Framework\Event\Observer $observer) { /** @var $themeFile \Magento\Theme\Model\Theme\File */ foreach ($this->currentTheme->getCustomization()->getFiles() as $themeFile) { try { $service = $themeFile->getCustomizationService(); if ($service instanceof \Magento\Framework\View\Design\Theme\Customization\FileAssetInterface) { $identifier = $themeFile->getData('file_path'); $dirPath = \Magento\Framework\View\Design\Theme\Customization\Path::DIR_NAME . '/' . $this->currentTheme->getId(); $asset = $this->assetRepo->createArbitrary($identifier, $dirPath, DirectoryList::MEDIA, \Magento\Framework\UrlInterface::URL_TYPE_MEDIA); $this->pageAssets->add($identifier, $asset); } } catch (\InvalidArgumentException $e) { $this->logger->critical($e); } } }
/** * @test * @return void */ public function testGetCustomization() { $this->customizationFactory->expects($this->once())->method('create')->willReturn($this->getMockBuilder('Magento\\Framework\\View\\Design\\Theme\\CustomizationInterface')->getMock()); $this->assertInstanceOf('Magento\\Framework\\View\\Design\\Theme\\CustomizationInterface', $this->_model->getCustomization()); }