protected function setUp() { $this->_themeFactory = $this->getMock('Magento\\Core\\Model\\ThemeFactory', array('create'), array(), '', false); $this->_theme = $this->getMock('Magento\\Core\\Model\\Theme', array('load', 'getId', 'getType', 'getDomainModel', 'isVirtual', '__wakeup'), array(), '', false); $this->_themeFactory->expects($this->any())->method('create')->will($this->returnValue($this->_theme)); $this->_copyService = $this->getMock('Magento\\Theme\\Model\\CopyService', array('copy'), array(), '', false); $this->_model = new \Magento\DesignEditor\Model\Theme\Context($this->_themeFactory, $this->_copyService); }
/** * Set theme which will be editable in store designer * * @param int $themeId * @return $this * @throws CoreException */ public function setEditableThemeById($themeId) { $this->_theme = $this->_themeFactory->create(); if (!$this->_theme->load($themeId)->getId()) { throw new CoreException(__('We can\'t find theme "%1".', $themeId)); } if ($this->_theme->getType() === \Magento\Framework\View\Design\ThemeInterface::TYPE_STAGING) { throw new CoreException(__('Wrong theme type set as editable')); } return $this; }
/** * Create theme customization * * @param \Magento\Framework\View\Design\ThemeInterface $theme * @return \Magento\Framework\View\Design\ThemeInterface */ public function createVirtualTheme($theme) { $themeData = $theme->getData(); $themeData['parent_id'] = $theme->getId(); $themeData['theme_id'] = null; $themeData['theme_path'] = null; $themeData['theme_title'] = $this->_getVirtualThemeTitle($theme); $themeData['type'] = \Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL; /** @var $themeCustomization \Magento\Framework\View\Design\ThemeInterface */ $themeCustomization = $this->_themeFactory->create()->setData($themeData); $themeCustomization->getThemeImage()->createPreviewImageCopy($theme); $themeCustomization->save(); $this->_themeCopyService->copy($theme, $themeCustomization); return $themeCustomization; }
/** * Design theme model getter * * @return \Magento\Core\Model\Theme */ public function getDesignTheme() { if ($this->_theme === null) { $this->_theme = $this->_themeFactory->create(); } return $this->_theme; }
/** * Create 'staging' theme associated with current 'virtual' theme * * @return \Magento\Framework\View\Design\ThemeInterface */ protected function _createStagingTheme() { $stagingTheme = $this->_themeFactory->create(); $stagingTheme->setData(array('parent_id' => $this->_theme->getId(), 'theme_path' => null, 'theme_version' => $this->_theme->getThemeVersion(), 'theme_title' => sprintf('%s - Staging', $this->_theme->getThemeTitle()), 'preview_image' => $this->_theme->getPreviewImage(), 'is_featured' => $this->_theme->getIsFeatured(), 'type' => \Magento\Framework\View\Design\ThemeInterface::TYPE_STAGING)); $stagingTheme->save(); return $stagingTheme; }
/** * {@inheritdoc} */ public function getThemeById($themeId) { /** @var $themeModel \Magento\Framework\View\Design\ThemeInterface */ $themeModel = $this->themeFactory->create(); return $themeModel->load($themeId); }