Example #1
0
 /**
  * Clean related contents to a theme (before save)
  *
  * @param EventObserver $observer
  * @return void
  * @throws Exception
  */
 public function cleanThemeRelatedContent(EventObserver $observer)
 {
     $theme = $observer->getEvent()->getData('theme');
     if ($theme instanceof \Magento\Framework\View\Design\ThemeInterface) {
         return;
     }
     /** @var $theme \Magento\Framework\View\Design\ThemeInterface */
     if ($this->_themeConfig->isThemeAssignedToStore($theme)) {
         throw new Exception(__('Theme isn\'t deletable.'));
     }
     $this->_themeImageFactory->create(array('theme' => $theme))->removePreviewImage();
     $this->_updateCollection->addThemeFilter($theme->getId())->delete();
 }
Example #2
0
 /**
  * Get theme image model
  *
  * @return \Magento\Framework\View\Design\Theme\Image
  */
 public function getThemeImage()
 {
     return $this->_imageFactory->create(['theme' => $this]);
 }