public function testGetCacheKeyInfo() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $context = $objectManager->get('Magento\\Framework\\App\\Http\\Context'); $context->setValue(Context::CONTEXT_AUTH, false, false); $block = $objectManager->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Theme\\Block\\Html\\Footer'); $storeId = $objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore()->getId(); $this->assertEquals(['PAGE_FOOTER', $storeId, 0, $this->_theme->getId(), null], $block->getCacheKeyInfo()); }
protected function setUp() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->_model = $objectManager->create('Magento\\Theme\\Model\\Theme\\File'); /** @var $themeModel \Magento\Framework\View\Design\ThemeInterface */ $themeModel = $objectManager->create('Magento\\Framework\\View\\Design\\ThemeInterface'); $this->_theme = $themeModel->getCollection()->getFirstItem(); $this->_data = ['file_path' => 'main.css', 'file_type' => 'css', 'content' => 'content files', 'order' => 0, 'theme' => $this->_theme, 'theme_id' => $this->_theme->getId()]; }
/** * 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); } } }
/** * Retrieve cache identifier taking into account current area/package/theme/store * * @param string $suffix * @return string */ protected function _getCacheId($suffix = '') { return "LAYOUT_{$this->_theme->getArea()}_STORE{$this->_store->getId()}_{$this->_theme->getId()}{$suffix}"; }