コード例 #1
0
ファイル: Repository.php プロジェクト: pavelnovitsky/magento2
 /**
  * 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;
 }
コード例 #2
0
 /**
  * Get default design parameter
  *
  * @param string $name
  * @return mixed
  */
 private function getDefaultParameter($name)
 {
     $this->defaults = $this->design->getDesignParams();
     return $this->defaults[$name];
 }