/** * Update required parameters with default values if custom not specified * * @param array &$params * @throws \UnexpectedValueException * @return $this * * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function updateDesignParams(array &$params) { $defaults = $this->design->getDesignParams(); // Set area if (empty($params['area'])) { $params['area'] = $defaults['area']; } // Set themeModel $theme = null; $area = $params['area']; if (!empty($params['themeId'])) { $theme = $params['themeId']; } elseif (isset($params['theme'])) { $theme = $params['theme']; } elseif (empty($params['themeModel']) && $area !== $defaults['area']) { $theme = $this->design->getConfigurationDesignTheme($area); } if ($theme) { $params['themeModel'] = $this->themeProvider->getThemeModel($theme, $area); if (!$params['themeModel']) { throw new \UnexpectedValueException("Could not find theme '{$theme}' for area '{$area}'"); } } elseif (empty($params['themeModel'])) { $params['themeModel'] = $defaults['themeModel']; } // Set module if (!array_key_exists('module', $params)) { $params['module'] = false; } // Set locale if (empty($params['locale'])) { $params['locale'] = $defaults['locale']; } return $this; }
/** * Get theme model based on the information from asset * * @param LocalInterface $asset * @return \Magento\Framework\View\Design\ThemeInterface */ protected function getTheme(LocalInterface $asset) { $context = $asset->getContext(); if ($context instanceof FallbackContext) { return $this->themeProvider->getThemeModel($context->getThemePath(), $context->getAreaCode()); } return $this->design->getDesignTheme(); }
/** * Find asset file via fallback mechanism * * @param LocalInterface $asset * @param \Magento\Framework\View\Asset\File\FallbackContext $context * @return bool|string */ private function findFileThroughFallback(LocalInterface $asset, \Magento\Framework\View\Asset\File\FallbackContext $context) { $themeModel = $this->themeProvider->getThemeModel($context->getThemePath(), $context->getAreaCode()); $sourceFile = $this->fallback->getFile($context->getAreaCode(), $themeModel, $context->getLocaleCode(), $asset->getFilePath(), $asset->getModule()); return $sourceFile; }