- /**
- * Creates or returns a shared model of theme
- *
- * @param string $themeKey
- * @param string $area
- * @return \Magento\Framework\View\Design\ThemeInterface|null
- * @throws \InvalidArgumentException
- * @throws \LogicException
- */
- public function create($themeKey, $area = \Magento\Framework\View\DesignInterface::DEFAULT_AREA)
- {
- if (!is_numeric($themeKey) && !is_string($themeKey)) {
- throw new \InvalidArgumentException('Incorrect theme identification key');
- }
- $themeKey = $this->extractThemeId($themeKey);
- if (is_numeric($themeKey)) {
- $themeModel = $this->_loadById($themeKey);
- } else {
- $themeModel = $this->_loadByPath($themeKey, $area);
- }
- if (!$themeModel->getId()) {
- throw new \LogicException("Unable to load theme by specified key: '{$themeKey}'");
- }
- $this->_addTheme($themeModel);
- return $themeModel;
- }