Skip to content

Commit 00cdd4f

Browse files
Merge remote-tracking branch 'remotes/github/MAGETWO-95805' into EPAM-PR-23
2 parents 3552903 + 5e8ae07 commit 00cdd4f

File tree

2 files changed

+23
-3
lines changed
  • app/code/Magento/Catalog
    • Test/Unit/Ui/DataProvider/Product/Listing/Collector
    • Ui/DataProvider/Product/Listing/Collector

2 files changed

+23
-3
lines changed

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Listing/Collector/ImageTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Catalog\Helper\ImageFactory;
1616
use Magento\Catalog\Api\Data\ProductRender\ImageInterface;
1717
use Magento\Catalog\Helper\Image as ImageHelper;
18+
use Magento\Framework\View\DesignLoader;
1819

1920
/**
2021
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -33,6 +34,9 @@ class ImageTest extends \PHPUnit\Framework\TestCase
3334
/** @var DesignInterface | \PHPUnit_Framework_MockObject_MockObject */
3435
private $design;
3536

37+
/** @var DesignLoader | \PHPUnit_Framework_MockObject_MockObject*/
38+
private $designLoader;
39+
3640
/** @var Image */
3741
private $model;
3842

@@ -60,13 +64,15 @@ public function setUp()
6064
->getMock();
6165
$this->storeManager = $this->createMock(StoreManagerInterface::class);
6266
$this->design = $this->createMock(DesignInterface::class);
67+
$this->designLoader = $this->createMock(DesignLoader::class);
6368
$this->model = new Image(
6469
$this->imageFactory,
6570
$this->state,
6671
$this->storeManager,
6772
$this->design,
6873
$this->imageInterfaceFactory,
69-
$this->imageCodes
74+
$this->imageCodes,
75+
$this->designLoader
7076
);
7177
}
7278

app/code/Magento/Catalog/Ui/DataProvider/Product/Listing/Collector/Image.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
use Magento\Framework\View\DesignInterface;
1818
use Magento\Store\Model\StoreManager;
1919
use Magento\Store\Model\StoreManagerInterface;
20+
use Magento\Framework\View\DesignLoader;
2021

2122
/**
2223
* Collect enough information about image rendering on front
2324
* If you want to add new image, that should render on front you need
2425
* to configure this class in di.xml
2526
*
27+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2628
*/
2729
class Image implements ProductRenderCollectorInterface
2830
{
@@ -51,6 +53,7 @@ class Image implements ProductRenderCollectorInterface
5153

5254
/**
5355
* @var DesignInterface
56+
* @deprecated 2.3.0 DesignLoader is used for design theme loading
5457
*/
5558
private $design;
5659

@@ -59,6 +62,11 @@ class Image implements ProductRenderCollectorInterface
5962
*/
6063
private $imageRenderInfoFactory;
6164

65+
/**
66+
* @var DesignLoader
67+
*/
68+
private $designLoader;
69+
6270
/**
6371
* Image constructor.
6472
* @param ImageFactory $imageFactory
@@ -67,21 +75,25 @@ class Image implements ProductRenderCollectorInterface
6775
* @param DesignInterface $design
6876
* @param ImageInterfaceFactory $imageRenderInfoFactory
6977
* @param array $imageCodes
78+
* @param DesignLoader $designLoader
7079
*/
7180
public function __construct(
7281
ImageFactory $imageFactory,
7382
State $state,
7483
StoreManagerInterface $storeManager,
7584
DesignInterface $design,
7685
ImageInterfaceFactory $imageRenderInfoFactory,
77-
array $imageCodes = []
86+
array $imageCodes = [],
87+
DesignLoader $designLoader = null
7888
) {
7989
$this->imageFactory = $imageFactory;
8090
$this->imageCodes = $imageCodes;
8191
$this->state = $state;
8292
$this->storeManager = $storeManager;
8393
$this->design = $design;
8494
$this->imageRenderInfoFactory = $imageRenderInfoFactory;
95+
$this->designLoader = $designLoader ?: \Magento\Framework\App\ObjectManager::getInstance()
96+
->get(DesignLoader::class);
8597
}
8698

8799
/**
@@ -124,6 +136,8 @@ public function collect(ProductInterface $product, ProductRenderInterface $produ
124136
}
125137

126138
/**
139+
* Callback for emulating image creation
140+
*
127141
* Callback in which we emulate initialize default design theme, depends on current store, be settings store id
128142
* from render info
129143
*
@@ -136,7 +150,7 @@ public function collect(ProductInterface $product, ProductRenderInterface $produ
136150
public function emulateImageCreating(ProductInterface $product, $imageCode, $storeId, ImageInterface $image)
137151
{
138152
$this->storeManager->setCurrentStore($storeId);
139-
$this->design->setDefaultDesignTheme();
153+
$this->designLoader->load();
140154

141155
$imageHelper = $this->imageFactory->create();
142156
$imageHelper->init($product, $imageCode);

0 commit comments

Comments
 (0)