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_FILE, 'file.ext', 'frontend', $theme, null, 'Magento_Module')->will($this->returnValue($expected)); $actual = $this->object->getFile('frontend', $theme, 'file.ext', 'Magento_Module'); $this->assertSame($expected, $actual); }
/** * Get existing file name with fallback to default * * @param string $fileId * @param array $params * @return string */ public function getFilename($fileId, array $params = []) { list($module, $filePath) = \Magento\Framework\View\Asset\Repository::extractModule($this->normalizePath($fileId)); if ($module) { $params['module'] = $module; } $this->_assetRepo->updateDesignParams($params); $file = $this->_fileResolution->getFile($params['area'], $params['themeModel'], $filePath, $params['module']); return $file; }
/** * 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; }
/** * Get existing file name, using fallback mechanism * * @param string $area * @param ThemeInterface $themeModel * @param string $file * @param string|null $module * @return string|bool */ public function getFile($area, ThemeInterface $themeModel, $file, $module = null) { $template = parent::getFile($area, $themeModel, $file, $module); if ($template && $this->assetConfig->isMinifyHtml()) { switch ($this->appState->getMode()) { case State::MODE_PRODUCTION: return $this->templateMinifier->getPathToMinified($template); case State::MODE_DEFAULT: return $this->templateMinifier->getMinified($template); case State::MODE_DEVELOPER: default: return $template; } } return $template; }