/**
  * Copy customizations stored in a database from one theme to another, overriding existing data
  *
  * @param ThemeInterface $source
  * @param ThemeInterface $target
  * @return void
  */
 protected function _copyDatabaseCustomization(ThemeInterface $source, ThemeInterface $target)
 {
     /** @var $themeFile \Magento\Theme\Model\Theme\File */
     foreach ($target->getCustomization()->getFiles() as $themeFile) {
         $themeFile->delete();
     }
     /** @var $newFile \Magento\Theme\Model\Theme\File */
     foreach ($source->getCustomization()->getFiles() as $themeFile) {
         /** @var $newThemeFile \Magento\Theme\Model\Theme\File */
         $newThemeFile = $this->_fileFactory->create();
         $newThemeFile->setData(['theme_id' => $target->getId(), 'file_path' => $themeFile->getFilePath(), 'file_type' => $themeFile->getFileType(), 'content' => $themeFile->getContent(), 'sort_order' => $themeFile->getData('sort_order')]);
         $newThemeFile->save();
     }
 }
Beispiel #2
0
 /**
  * Create class instance with specified parameters
  *
  * @return \Magento\Framework\View\Design\Theme\FileInterface
  */
 public function create()
 {
     $file = $this->_fileFactory->create();
     $file->setCustomizationService($this);
     return $file;
 }