/** * {@inheritdoc} */ public function resolve($type, $file, $area = null, ThemeInterface $theme = null, $locale = null, $module = null) { self::assertFilePathFormat($file); $themePath = $theme ? $theme->getThemePath() : ''; $path = $this->cache->getFromCache($type, $file, $area, $themePath, $locale, $module); if (false !== $path) { $path = $path ? $this->rootDirectory->getAbsolutePath($path) : false; } else { $params = ['area' => $area, 'theme' => $theme, 'locale' => $locale]; foreach ($params as $key => $param) { if ($param === null) { unset($params[$key]); } } if (!empty($module)) { list($params['namespace'], $params['module']) = explode('_', $module, 2); } $path = $this->resolveFile($this->rulePool->getRule($type), $file, $params); $cachedValue = $path ? $this->rootDirectory->getRelativePath($path) : ''; $this->cache->saveToCache($cachedValue, $type, $file, $area, $themePath, $locale, $module); } return $path; }
/** * {@inheritdoc} */ public function setTheme(\Magento\Framework\View\Design\ThemeInterface $theme) { $this->_theme = $theme; $this->setData('theme_id', $theme->getId()); $this->setData('theme_path', $theme->getThemePath()); return $this; }
/** * {@inheritdoc} */ public function getThemePath(\Magento\Framework\View\Design\ThemeInterface $theme) { $themePath = $theme->getThemePath(); if (!$themePath) { $themeId = $theme->getId(); if ($themeId) { $themePath = self::PUBLIC_THEME_DIR . $themeId; } else { $themePath = self::PUBLIC_VIEW_DIR; } } return $themePath; }
/** * Checks that a theme present in filesystem collection * * @param ThemeInterface $theme * @return bool */ public function hasTheme(ThemeInterface $theme) { $themeItems = $this->getItems(); return $theme->getThemePath() && isset($themeItems[$theme->getFullPath()]); }