Skip to content

Commit 27762b8

Browse files
PB-341: Save content as template
- fix media sync - fix static test
1 parent 0043627 commit 27762b8

File tree

2 files changed

+7
-9
lines changed
  • app/code/Magento/PageBuilder

2 files changed

+7
-9
lines changed

app/code/Magento/PageBuilder/Controller/Adminhtml/Template/Save.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class Save extends Action implements HttpPostActionInterface
9191
* @param ImageContentFactory $imageContentFactory
9292
* @param Database $mediaStorage
9393
* @param AdapterFactory $imageAdapterFactory
94+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
9495
*/
9596
public function __construct(
9697
Context $context,
@@ -254,19 +255,16 @@ private function storePreviewImage(RequestInterface $request) : ?string
254255
$decodedImage
255256
);
256257

257-
// If the media storage is set to DB also save the file into the DB
258-
if ($this->mediaStorage->checkDbUsage()) {
259-
$this->mediaStorage->saveFile(
260-
$filePath
261-
);
262-
}
263-
264258
// Generate a thumbnail, called -thumb next to the image for usage in the grid
265259
$absolutePath = $mediaDir->getAbsolutePath() . $filePath;
260+
$thumbPath = str_replace('.jpg', '-thumb.jpg', $filePath);
261+
$thumbAbsolutePath = $mediaDir->getAbsolutePath() . $thumbPath;
266262
$imageFactory = $this->imageAdapterFactory->create();
267263
$imageFactory->open($absolutePath);
268264
$imageFactory->resize(350);
269-
$imageFactory->save(str_replace('.jpg', '-thumb.jpg', $absolutePath));
265+
$imageFactory->save($thumbAbsolutePath);
266+
$this->mediaStorage->saveFile($filePath);
267+
$this->mediaStorage->saveFile($thumbPath);
270268

271269
// Store the preview image within the new entity
272270
return $filePath;

app/code/Magento/PageBuilder/Model/ResourceModel/Template/Grid/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Collection extends TemplateCollection implements SearchResultInterface
2929
/**
3030
* @var AggregationInterface
3131
*/
32-
protected $aggregations;
32+
private $aggregations;
3333

3434
/**
3535
* @param EntityFactoryInterface $entityFactory

0 commit comments

Comments
 (0)