46 private $deploymentConfig;
65 Json $serializer =
null 78 if (isset($this->themes[$fullPath])) {
79 return $this->themes[$fullPath];
82 if (! $this->getDeploymentConfig()->isDbAvailable()) {
83 return $this->getThemeList()->getThemeByFullPath($fullPath);
86 $theme = $this->loadThemeFromCache(
'theme' . $fullPath);
88 $this->themes[$fullPath] =
$theme;
91 $themeCollection = $this->collectionFactory->create();
92 $theme = $themeCollection->getThemeByFullPath($fullPath);
94 $this->saveThemeToCache(
$theme,
'theme' . $fullPath);
95 $this->saveThemeToCache(
$theme,
'theme-by-id-' .
$theme->getId());
96 $this->themes[$fullPath] =
$theme;
106 $area = \
Magento\Framework\
App\Area::AREA_FRONTEND,
110 $themeCollection = $this->collectionFactory->create();
111 $themeCollection->addAreaFilter($area)->addTypeFilter(
$type);
112 return $themeCollection;
120 if (isset($this->themes[$themeId])) {
121 return $this->themes[$themeId];
123 $theme = $this->loadThemeFromCache(
'theme-by-id-' . $themeId);
125 $this->themes[$themeId] =
$theme;
128 $theme = $this->themeFactory->create();
132 $this->saveThemeToCache(
$theme,
'theme-by-id-' . $themeId);
133 $this->themes[$themeId] =
$theme;
144 private function loadThemeFromCache($cacheId)
146 $themeData = $this->cache->load($cacheId);
148 $themeData = $this->serializer->unserialize($themeData);
149 $theme = $this->themeFactory->create()->populateFromArray($themeData);
163 private function saveThemeToCache(\
Magento\Theme\Model\Theme
$theme, $cacheId)
165 $themeData = $this->serializer->serialize(
$theme->toArray());
166 $this->cache->save($themeData, $cacheId);
173 private function getThemeList()
175 if ($this->themeList ===
null) {
178 return $this->themeList;
185 private function getDeploymentConfig()
187 if ($this->deploymentConfig ===
null) {
190 return $this->deploymentConfig;
getThemeCustomizations($area, $type=\Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL)
__construct(\Magento\Theme\Model\ResourceModel\Theme\CollectionFactory $collectionFactory, \Magento\Theme\Model\ThemeFactory $themeFactory, \Magento\Framework\App\CacheInterface $cache, Json $serializer=null)
getThemeByFullPath($fullPath)