public function testGetFile() { $theme = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Design\\ThemeInterface'); $expected = 'some/file.ext'; $this->resolver->expects($this->once())->method('resolve')->with(RulePool::TYPE_STATIC_FILE, 'file.ext', 'frontend', $theme, 'en_US', 'Magento_Module')->will($this->returnValue($expected)); $actual = $this->object->getFile('frontend', $theme, 'en_US', 'file.ext', 'Magento_Module'); $this->assertSame($expected, $actual); }
/** * Find a static view file using fallback mechanism * * @param string $fileId * @param array $params * @return string */ public function getStaticFileName($fileId, array $params = []) { list($module, $filePath) = \Magento\Framework\View\Asset\Repository::extractModule($this->normalizePath($fileId)); if ($module) { $params['module'] = $module; } $this->_assetRepo->updateDesignParams($params); return $this->_staticFileResolution->getFile($params['area'], $params['themeModel'], $params['locale'], $filePath, $params['module']); }
/** * Get static file through fallback system using specified params * * @param string $area * @param string|\Magento\Framework\View\Design\ThemeInterface $theme - either theme path (string) or theme object * @param string $locale * @param string $filePath * @param string $module * @param bool $isExplicit * @return bool|string */ private function getStaticFile($area, $theme, $locale, $filePath, $module, $isExplicit = false) { if (!is_object($theme)) { $themePath = $theme ?: $this->getDefaultThemePath($area); $theme = $this->themeRepo->create($themePath, $area); } if ($isExplicit) { $type = \Magento\Framework\View\Design\Fallback\RulePool::TYPE_STATIC_FILE; return $this->explicitFallback->resolve($type, $filePath, $area, $theme, $locale, $module); } return $this->fallback->getFile($area, $theme, $locale, $filePath, $module); }
/** * Find asset file via fallback mechanism * * @param LocalInterface $asset * @param \Magento\Framework\View\Asset\File\FallbackContext $context * @return bool|string */ private function findFileThroughFallback( LocalInterface $asset, \Magento\Framework\View\Asset\File\FallbackContext $context ) { $themeModel = $this->themeList->getThemeByFullPath($context->getAreaCode() . '/' . $context->getThemePath()); $sourceFile = $this->fallback->getFile( $context->getAreaCode(), $themeModel, $context->getLocale(), $asset->getFilePath(), $asset->getModule() ); return $sourceFile; }
/** * Resolves file to find its fallback'ed paths * * @param \Magento\Framework\View\Design\ThemeInterface $theme * @param string $file * @return array */ protected function _getFileResolutions(\Magento\Framework\View\Design\ThemeInterface $theme, $file) { $found = array(); $fileResolved = self::$_filesFallback->getFile($theme->getArea(), $theme, $file); if (file_exists($fileResolved)) { $found[$fileResolved] = $fileResolved; } foreach (self::$_checkThemeLocales[$theme->getFullPath()] as $locale) { $fileResolved = self::$_viewFilesFallback->getFile($theme->getArea(), $theme, $locale, $file); if (file_exists($fileResolved)) { $found[$fileResolved] = $fileResolved; } } return $found; }