Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Design Class Reference
Inheritance diagram for Design:
DesignInterface

Public Member Functions

 __construct (\Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\View\Design\Theme\FlyweightFactory $flyweightFactory, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Theme\Model\ThemeFactory $themeFactory, \Magento\Framework\ObjectManagerInterface $objectManager, \Magento\Framework\App\State $appState, array $themes)
 
 setArea ($area)
 
 getArea ()
 
 setDesignTheme ($theme, $area=null)
 
 getConfigurationDesignTheme ($area=null, array $params=[])
 
 setDefaultDesignTheme ()
 
 getDesignTheme ()
 
 getThemePath (\Magento\Framework\View\Design\ThemeInterface $theme)
 
 getLocale ()
 
 setLocale (\Magento\Framework\Locale\ResolverInterface $locale)
 
 getDesignParams ()
 
- Public Member Functions inherited from DesignInterface
 getThemePath (Design\ThemeInterface $theme)
 

Protected Attributes

 $_area
 
 $_theme
 
 $_callbackFileDir
 
 $_storeManager
 
 $_flyweightFactory
 
 $_themeFactory
 
 $_locale
 
 $objectManager
 
 $_appState
 

Additional Inherited Members

- Data Fields inherited from DesignInterface
const DEFAULT_AREA = 'frontend'
 
const PUBLIC_VIEW_DIR = '_view'
 
const PUBLIC_THEME_DIR = '_theme'
 
const XML_PATH_THEME_ID = 'design/theme/theme_id'
 

Detailed Description

Keeps design settings for current request

Definition at line 15 of file Design.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Store\Model\StoreManagerInterface  $storeManager,
\Magento\Framework\View\Design\Theme\FlyweightFactory  $flyweightFactory,
\Magento\Framework\App\Config\ScopeConfigInterface  $scopeConfig,
\Magento\Theme\Model\ThemeFactory  $themeFactory,
\Magento\Framework\ObjectManagerInterface  $objectManager,
\Magento\Framework\App\State  $appState,
array  $themes 
)
Parameters
\Magento\Store\Model\StoreManagerInterface$storeManager
\Magento\Framework\View\Design\Theme\FlyweightFactory$flyweightFactory
\Magento\Framework\App\Config\ScopeConfigInterface$scopeConfig
\Magento\Theme\Model\ThemeFactory$themeFactory
\Magento\Framework\ObjectManagerInterface$objectManager
\Magento\Framework\App\State$appState
array$themes

Definition at line 85 of file Design.php.

93  {
94  $this->_storeManager = $storeManager;
95  $this->_flyweightFactory = $flyweightFactory;
96  $this->_themeFactory = $themeFactory;
97  $this->_scopeConfig = $scopeConfig;
98  $this->_appState = $appState;
99  $this->_themes = $themes;
100  $this->objectManager = $objectManager;
101  }
$storeManager

Member Function Documentation

◆ getArea()

getArea ( )

Retrieve package area

Returns
string

Implements DesignInterface.

Definition at line 121 of file Design.php.

122  {
123  // In order to support environment emulation of area, if area is set, return it
124  if ($this->_area && !$this->_appState->isAreaCodeEmulated()) {
125  return $this->_area;
126  }
127  return $this->_appState->getAreaCode();
128  }

◆ getConfigurationDesignTheme()

getConfigurationDesignTheme (   $area = null,
array  $params = [] 
)

Get default theme which declared in configuration

Write default theme to core_config_data

Parameters
string | null$area
array$params
Returns
string|int

Implements DesignInterface.

Definition at line 163 of file Design.php.

164  {
165  if (!$area) {
166  $area = $this->getArea();
167  }
168 
169  $theme = null;
170  $store = isset($params['store']) ? $params['store'] : null;
171 
172  if ($this->_isThemePerStoreView($area)) {
173  if ($this->_storeManager->isSingleStoreMode()) {
174  $theme = $this->_scopeConfig->getValue(
175  self::XML_PATH_THEME_ID,
177  );
178  } else {
179  $theme = (string) $this->_scopeConfig->getValue(
180  self::XML_PATH_THEME_ID,
182  $store
183  );
184  }
185  }
186 
187  if (!$theme && isset($this->_themes[$area])) {
188  $theme = $this->_themes[$area];
189  }
190 
191  return $theme;
192  }
$theme
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ getDesignParams()

getDesignParams ( )

{Get design settings for current request

Returns
array
}

Implements DesignInterface.

Definition at line 272 of file Design.php.

273  {
274  $params = [
275  'area' => $this->getArea(),
276  'themeModel' => $this->getDesignTheme(),
277  'locale' => $this->getLocale(),
278  ];
279 
280  return $params;
281  }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ getDesignTheme()

getDesignTheme ( )

Design theme model getter

Returns
\Magento\Theme\Model\Theme

Implements DesignInterface.

Definition at line 221 of file Design.php.

222  {
223  if ($this->_theme === null) {
224  $this->_theme = $this->_themeFactory->create();
225  }
226  return $this->_theme;
227  }

◆ getLocale()

getLocale ( )

Get locale

Returns
string

Implements DesignInterface.

Definition at line 251 of file Design.php.

252  {
253  if (null === $this->_locale) {
254  $this->_locale = $this->objectManager->get(\Magento\Framework\Locale\ResolverInterface::class);
255  }
256  return $this->_locale->getLocale();
257  }

◆ getThemePath()

{}

Definition at line 232 of file Design.php.

233  {
234  $themePath = $theme->getThemePath();
235  if (!$themePath) {
236  $themeId = $theme->getId();
237  if ($themeId) {
238  $themePath = self::PUBLIC_THEME_DIR . $themeId;
239  } else {
240  $themePath = self::PUBLIC_VIEW_DIR;
241  }
242  }
243  return $themePath;
244  }
$theme

◆ setArea()

setArea (   $area)

Set package area

Parameters
string$area
Returns
$this

Implements DesignInterface.

Definition at line 109 of file Design.php.

110  {
111  $this->_area = $area;
112  $this->_theme = null;
113  return $this;
114  }

◆ setDefaultDesignTheme()

setDefaultDesignTheme ( )

Set default design theme

Returns
$this

Implements DesignInterface.

Definition at line 210 of file Design.php.

211  {
213  return $this;
214  }
getConfigurationDesignTheme($area=null, array $params=[])
Definition: Design.php:163
setDesignTheme($theme, $area=null)
Definition: Design.php:137

◆ setDesignTheme()

setDesignTheme (   $theme,
  $area = null 
)

Set theme path

Parameters
\Magento\Framework\View\Design\ThemeInterface | string$theme
string$area
Returns
$this

Implements DesignInterface.

Definition at line 137 of file Design.php.

138  {
139  if ($area) {
140  $this->setArea($area);
141  } else {
142  $area = $this->getArea();
143  }
144 
145  if ($theme instanceof \Magento\Framework\View\Design\ThemeInterface) {
146  $this->_theme = $theme;
147  } else {
148  $this->_theme = $this->_flyweightFactory->create($theme, $area);
149  }
150 
151  return $this;
152  }
$theme

◆ setLocale()

Parameters
\Magento\Framework\Locale\ResolverInterface$locale
Returns
$this

Definition at line 263 of file Design.php.

264  {
265  $this->_locale = $locale;
266  return $this;
267  }

Field Documentation

◆ $_appState

$_appState
protected

Definition at line 74 of file Design.php.

◆ $_area

$_area
protected

Definition at line 22 of file Design.php.

◆ $_callbackFileDir

$_callbackFileDir
protected

Definition at line 37 of file Design.php.

◆ $_flyweightFactory

$_flyweightFactory
protected

Definition at line 49 of file Design.php.

◆ $_locale

$_locale
protected

Definition at line 64 of file Design.php.

◆ $_storeManager

$_storeManager
protected

Definition at line 44 of file Design.php.

◆ $_theme

$_theme
protected

Definition at line 29 of file Design.php.

◆ $_themeFactory

$_themeFactory
protected

Definition at line 54 of file Design.php.

◆ $objectManager

$objectManager
protected

Definition at line 69 of file Design.php.


The documentation for this class was generated from the following file: