コード例 #1
0
ファイル: Config.php プロジェクト: pradeep-wagento/magento2
 /**
  * Render view config object for current package and theme
  *
  * @param array $params
  * @return \Magento\Framework\Config\View
  */
 public function getViewConfig(array $params = [])
 {
     $this->assetRepo->updateDesignParams($params);
     /** @var $currentTheme \Magento\Framework\View\Design\ThemeInterface */
     $currentTheme = $params['themeModel'];
     $key = $currentTheme->getCode();
     if (isset($this->viewConfigs[$key])) {
         return $this->viewConfigs[$key];
     }
     $config = $this->viewConfigFactory->create();
     $this->viewConfigs[$key] = $config;
     return $config;
 }
コード例 #2
0
ファイル: Config.php プロジェクト: nblair/magescotch
    /**
     * Render view config object for current package and theme
     *
     * @param array $params
     * @return \Magento\Framework\Config\View
     */
    public function getViewConfig(array $params = [])
    {
        $this->assetRepo->updateDesignParams($params);
        /** @var $currentTheme \Magento\Framework\View\Design\ThemeInterface */
        $currentTheme = $params['themeModel'];
        $key = $currentTheme->getCode();
        if (isset($this->viewConfigs[$key])) {
            return $this->viewConfigs[$key];
        }

        $configFiles = $this->moduleReader->getConfigurationFiles(basename($this->filename))->toArray();
        $themeConfigFile = $currentTheme->getCustomization()->getCustomViewConfigPath();
        if (empty($themeConfigFile)
            || !$this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))
        ) {
            $themeConfigFile = $this->viewFileSystem->getFilename($this->filename, $params);
        }
        if ($themeConfigFile
            && $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))
        ) {
            $configFiles[$this->rootDirectory->getRelativePath($themeConfigFile)] = $this->rootDirectory->readFile(
                $this->rootDirectory->getRelativePath($themeConfigFile)
            );
        }
        $config = $this->viewFactory->create($configFiles);

        $this->viewConfigs[$key] = $config;
        return $config;
    }
コード例 #3
0
 /**
  * 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']);
 }
コード例 #4
0
ファイル: Config.php プロジェクト: Doability/magento2dev
 /**
  * Render view config object for current package and theme
  *
  * @param array $params
  * @return \Magento\Framework\Config\View
  */
 public function getViewConfig(array $params = [])
 {
     $this->assetRepo->updateDesignParams($params);
     $viewConfigParams = [];
     if (isset($params['themeModel'])) {
         /** @var \Magento\Framework\View\Design\ThemeInterface $currentTheme */
         $currentTheme = $params['themeModel'];
         $key = $currentTheme->getCode();
         if (isset($this->viewConfigs[$key])) {
             return $this->viewConfigs[$key];
         }
         $viewConfigParams['themeModel'] = $currentTheme;
     }
     $viewConfigParams['area'] = isset($params['area']) ? $params['area'] : null;
     /** @var \Magento\Framework\Config\View $config */
     $config = $this->viewConfigFactory->create($viewConfigParams);
     if (isset($key)) {
         $this->viewConfigs[$key] = $config;
     }
     return $config;
 }
コード例 #5
0
ファイル: FileSystem.php プロジェクト: Doability/magento2dev
 /**
  * Get an email template file
  *
  * @param string $fileId
  * @param array $params
  * @param string $module
  * @return string|bool
  */
 public function getEmailTemplateFileName($fileId, array $params, $module)
 {
     $this->_assetRepo->updateDesignParams($params);
     return $this->_emailTemplateFileResolution->getFile($params['area'], $params['themeModel'], $params['locale'], $fileId, $module);
 }
コード例 #6
0
 /**
  * @expectedException \UnexpectedValueException
  * @expectedExceptionMessage Could not find theme 'nonexistent_theme' for area 'area'
  */
 public function testUpdateDesignParamsWrongTheme()
 {
     $params = ['area' => 'area', 'theme' => 'nonexistent_theme'];
     $this->themeList->expects($this->once())->method('getThemeByFullPath')->with('area/nonexistent_theme')->will($this->returnValue(null));
     $this->object->updateDesignParams($params);
 }
コード例 #7
0
 /**
  * @param array $params
  * @param array $result
  * @return void
  * @dataProvider updateDesignParamsDataProvider
  */
 public function testUpdateDesignParams($params, $result)
 {
     $this->themeProvider->expects($this->any())->method('getThemeByFullPath')->willReturn('ThemeID');
     $this->repository->updateDesignParams($params);
     $this->assertEquals($result, $params);
 }