/** * {@inheritdoc} */ public function get($filename, $scope) { switch ($scope) { case 'global': $iterator = $this->moduleReader->getConfigurationFiles($filename)->toArray(); $themeConfigFile = $this->currentTheme->getCustomization()->getCustomViewConfigPath(); if ($themeConfigFile && $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))) { $iterator[$this->rootDirectory->getRelativePath($themeConfigFile)] = $this->rootDirectory->readFile($this->rootDirectory->getRelativePath($themeConfigFile)); } else { $designPath = $this->resolver->resolve(RulePool::TYPE_FILE, 'etc/view.xml', $this->area, $this->currentTheme); if (file_exists($designPath)) { try { $designDom = new \DOMDocument(); $designDom->load($designPath); $iterator[$designPath] = $designDom->saveXML(); } catch (\Exception $e) { throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Could not read config file')); } } } break; default: $iterator = $this->iteratorFactory->create([]); break; } return $iterator; }
/** * Get path of file after using fallback rules * * @param string $type * @param string $file * @param string|null $area * @param ThemeInterface|null $theme * @param string|null $locale * @param string|null $module * @return string|false */ public function resolve($type, $file, $area = null, ThemeInterface $theme = null, $locale = null, $module = null) { $path = $this->fallback->resolve($type, $file, $area, $theme, $locale, $module); if (!$path && $file != ($newFile = $this->minification->removeMinifiedSign($file))) { $path = $this->fallback->resolve($type, $newFile, $area, $theme, $locale, $module); } return $path; }
/** * Recursively add parent theme configs * * @param ThemeInterface $theme * @param array $iterator * @param int $index * @return array */ private function getParentConfigs(ThemeInterface $theme, array $iterator, $index = 0) { if ($theme->getParentTheme() && $theme->isPhysical()) { $parentDesignPath = $this->resolver->resolve(RulePool::TYPE_FILE, 'etc/view.xml', $this->area, $theme->getParentTheme()); $parentDom = new \DOMDocument(); $parentDom->load($parentDesignPath); $iterator[$index] = $parentDom->saveXML(); $iterator = $this->getParentConfigs($theme->getParentTheme(), $iterator, ++$index); } return $iterator; }
/** * Get path of file after using fallback rules * * @param string $type * @param string $file * @param string|null $area * @param ThemeInterface|null $theme * @param string|null $locale * @param string|null $module * @return string|false */ private function resolveJsMinification( $type, $file, $area = null, ThemeInterface $theme = null, $locale = null, $module = null ) { $path = $this->fallback->resolve($type, $file, $area, $theme, $locale, $module); /** * Minified version as priority one */ if ($path && $this->minification->isMinifiedFilename($path)) { return $path; } /** * If minification is disabled - return already found path */ if (!$this->minification->isEnabled('js')) { return $path; } /** * Try to find minified version of file, * or return already found path */ return $this->fallback->resolve( $type, $this->minification->addMinifiedSign($file), $area, $theme, $locale, $module ) ?: $path; }
/** * 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) { return $this->resolver->resolve($this->getFallbackType(), $file, $area, $themeModel, null, $module); }