Пример #1
0
 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);
 }
Пример #2
0
 public function testGetFilename()
 {
     $params = array('area' => 'some_area', 'themeModel' => $this->getMock('Magento\\Framework\\View\\Design\\ThemeInterface', array(), array(), '', false, false), 'module' => 'Some_Module');
     $file = 'Some_Module::some_file.ext';
     $expected = 'path/to/some_file.ext';
     $this->_fileResolution->expects($this->once())->method('getFile')->with($params['area'], $params['themeModel'], 'some_file.ext', 'Some_Module')->will($this->returnValue($expected));
     $this->_assetRepo->expects($this->any())->method('extractScope')->with($file, $params)->will($this->returnValue('some_file.ext'));
     $actual = $this->_model->getFilename($file, $params);
     $this->assertEquals($expected, $actual);
 }
Пример #3
0
 /**
  * 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;
 }
Пример #4
0
 /**
  * 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;
 }
Пример #5
0
 /**
  * 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;
 }