コード例 #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
ファイル: 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;
 }
コード例 #4
0
 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage wrong theme doesn't implement ThemeInterface
  */
 public function testCreateException()
 {
     $this->model->create(['themeModel' => 'wrong theme', 'area' => self::AREA]);
 }