currentTheme = $design->getDesignTheme(); $this->pageAssets = $assets; $this->assetRepo = $assetRepo; $this->logger = $logger; } /** * 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); } } } }