59 \
Magento\Widget\Model\Layout\UpdateFactory $updateFactory,
60 \
Magento\Framework\Event\ManagerInterface $eventManager,
64 $this->_fileFactory = $fileFactory;
66 $this->_updateFactory = $updateFactory;
67 $this->_eventManager = $eventManager;
68 $this->_customizationPath = $customization;
95 foreach (
$target->getCustomization()->getFiles() as $themeFile) {
99 foreach (
$source->getCustomization()->getFiles() as $themeFile) {
101 $newThemeFile = $this->_fileFactory->create();
102 $newThemeFile->setData(
104 'theme_id' =>
$target->getId(),
105 'file_path' => $themeFile->getFilePath(),
106 'file_type' => $themeFile->getFileType(),
107 'content' => $themeFile->getContent(),
108 'sort_order' => $themeFile->getData(
'sort_order'),
111 $newThemeFile->save();
122 protected function _copyLayoutCustomization(ThemeInterface
$source, ThemeInterface
$target)
124 $update = $this->_updateFactory->create();
126 $targetUpdates = $update->getCollection();
127 $targetUpdates->addThemeFilter(
$target->getId());
128 $targetUpdates->delete();
131 $sourceCollection = $this->_link->getCollection();
132 $sourceCollection->addThemeFilter(
$source->getId());
134 foreach ($sourceCollection as $layoutLink) {
136 $update = $this->_updateFactory->create();
137 $update->load($layoutLink->getLayoutUpdateId());
138 if ($update->getId()) {
139 $update->setId(
null);
141 $layoutLink->setThemeId(
$target->getId());
142 $layoutLink->setLayoutUpdateId($update->getId());
143 $layoutLink->setId(
null);
158 $sourcePath = $this->_customizationPath->getCustomizationPath(
$source);
159 $targetPath = $this->_customizationPath->getCustomizationPath(
$target);
161 if (!$sourcePath || !$targetPath) {
167 if ($this->_directory->isDirectory($sourcePath)) {
182 foreach ($this->_directory->read($sourceDir) as
$path) {
183 if ($this->_directory->isDirectory(
$path)) {
187 $this->_directory->copyFile(
$path, $targetDir .
'/' . $filePath);
200 if ($this->_directory->isExist($targetDir)) {
201 foreach ($this->_directory->read($targetDir) as
$path) {
202 $this->_directory->delete(
$path);
_copyFilesystemCustomization(ThemeInterface $source, ThemeInterface $target)
copy(ThemeInterface $source, ThemeInterface $target)
_copyFilesRecursively($baseDir, $sourceDir, $targetDir)
__construct(\Magento\Framework\Filesystem $filesystem, \Magento\Framework\View\Design\Theme\FileFactory $fileFactory, \Magento\Widget\Model\Layout\Link $link, \Magento\Widget\Model\Layout\UpdateFactory $updateFactory, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\View\Design\Theme\Customization\Path $customization)
_deleteFilesRecursively($targetDir)