示例#1
0
 /**
  * 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->themeList->getThemeByFullPath($area . '/' . $theme);
         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->themeList->getThemeByFullPath($context->getAreaCode() . '/' . $context->getThemePath());
     }
     return $this->design->getDesignTheme();
 }
示例#3
0
文件: Source.php 项目: nja78/magento2
 /**
  * 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->themeList->getThemeByFullPath($context->getAreaCode() . '/' . $context->getThemePath());
     $sourceFile = $this->fallback->getFile(
         $context->getAreaCode(),
         $themeModel,
         $context->getLocale(),
         $asset->getFilePath(),
         $asset->getModule()
     );
     return $sourceFile;
 }
示例#4
0
 /**
  * @param FallbackContext $assetContext
  * @return \Magento\Framework\Config\View
  */
 public function getConfig(FallbackContext $assetContext)
 {
     return $this->viewConfig->getViewConfig(['area' => $assetContext->getAreaCode(), 'themeModel' => $this->themeList->getThemeByFullPath($assetContext->getAreaCode() . '/' . $assetContext->getThemePath())]);
 }