Skip to content

Commit d866ad8

Browse files
committed
#3401: Decouple product view gallery images config from Gallery Block
- Code style fixes
1 parent 8676464 commit d866ad8

File tree

4 files changed

+26
-34
lines changed

4 files changed

+26
-34
lines changed

app/code/Magento/Catalog/Block/Product/View/Gallery.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Magento\Framework\DataObject;
2020
use Magento\Framework\App\ObjectManager;
2121
use Magento\Framework\Json\EncoderInterface;
22-
use Magento\Framework\Serialize\Serializer\Json;
2322
use Magento\Framework\Stdlib\ArrayUtils;
2423

2524
/**
@@ -38,22 +37,22 @@ class Gallery extends AbstractView
3837
protected $jsonEncoder;
3938

4039
/**
41-
* @var DataObject
40+
* @var array
4241
*/
43-
protected $galleryImagesConfig;
42+
private $galleryImagesConfig;
4443

4544
/**
4645
* @var ImagesConfigFactoryInterface
4746
*/
4847
private $galleryImagesConfigFactory;
4948

5049
/**
51-
* @param Context $context
52-
* @param ArrayUtils $arrayUtils
53-
* @param EncoderInterface $jsonEncoder
50+
* @param Context $context
51+
* @param ArrayUtils $arrayUtils
52+
* @param EncoderInterface $jsonEncoder
53+
* @param array $data
5454
* @param ImagesConfigFactoryInterface $imagesConfigFactory
55-
* @param array $galleryImagesConfig
56-
* @param array $data
55+
* @param array $galleryImagesConfig
5756
*/
5857
public function __construct(
5958
Context $context,
@@ -64,8 +63,9 @@ public function __construct(
6463
array $galleryImagesConfig = []
6564
) {
6665
parent::__construct($context, $arrayUtils, $data);
67-
$this->jsonEncoder = $jsonEncoder ?: ObjectManager::getInstance()->get(Json::class);
68-
$this->galleryImagesConfigFactory = $imagesConfigFactory ?: ObjectManager::getInstance()->get(ImagesConfigFactoryInterface::class);
66+
$this->jsonEncoder = $jsonEncoder;
67+
$this->galleryImagesConfigFactory = $imagesConfigFactory ?: ObjectManager::getInstance()
68+
->get(ImagesConfigFactoryInterface::class);
6969
$this->galleryImagesConfig = $galleryImagesConfig;
7070
}
7171

@@ -211,7 +211,8 @@ private function getConfigView()
211211
private function getGalleryImagesConfig()
212212
{
213213
if (false === $this->hasData('gallery_images_config')) {
214-
$this->setData('gallery_images_config', $this->galleryImagesConfigFactory->create($this->galleryImagesConfig));
214+
$galleryImageConfig = $this->galleryImagesConfigFactory->create($this->galleryImagesConfig);
215+
$this->setData('gallery_images_config', $galleryImageConfig);
215216
}
216217

217218
return $this->getData('gallery_images_config');

app/code/Magento/Catalog/Model/Product/Gallery/ImagesConfigFactory.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
<?php
22
/**
3-
*
4-
* Copyright © 2015 Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Catalog\Model\Product\Gallery;
87

9-
use \Magento\Framework\Data\CollectionFactory;
8+
use Magento\Framework\Data\CollectionFactory;
109
use Magento\Framework\DataObject;
1110

1211
class ImagesConfigFactory implements ImagesConfigFactoryInterface
1312
{
1413
/**
15-
* @var \Magento\Framework\Data\CollectionFactory
14+
* @var CollectionFactory
1615
*/
1716
protected $dataCollectionFactory;
1817

1918
/**
20-
* ImagesConfigFactory constructor.
21-
*
2219
* @param CollectionFactory $dataCollectionFactory
2320
*/
2421
public function __construct(CollectionFactory $dataCollectionFactory)
@@ -27,12 +24,7 @@ public function __construct(CollectionFactory $dataCollectionFactory)
2724
}
2825

2926
/**
30-
* create Gallery Images Config Collection from array
31-
*
32-
* @param array $imagesConfig
33-
* @param array $data
34-
*
35-
* @return \Magento\Framework\Data\Collection
27+
* @inheritdoc
3628
*/
3729
public function create(array $imagesConfig, array $data = [])
3830
{

app/code/Magento/Catalog/Model/Product/Gallery/ImagesConfigFactoryInterface.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<?php
22
/**
3-
*
4-
* Copyright © 2015 Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Catalog\Model\Product\Gallery;
87

98
interface ImagesConfigFactoryInterface
109
{
1110
/**
12-
* create Gallery Images Config Collection from array
11+
* Create Gallery Images Config Collection from array
1312
*
1413
* @param array $imagesConfig
1514
* @param array $data

app/code/Magento/ProductVideo/Block/Product/View/Gallery.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ class Gallery extends \Magento\Catalog\Block\Product\View\Gallery
2222
protected $mediaHelper;
2323

2424
/**
25-
* @param \Magento\Catalog\Block\Product\Context $context
26-
* @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils
27-
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
28-
* @param \Magento\ProductVideo\Helper\Media $mediaHelper
25+
* @param \Magento\Catalog\Block\Product\Context $context
26+
* @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils
27+
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
28+
* @param \Magento\ProductVideo\Helper\Media $mediaHelper
29+
* @param array $data
2930
* @param \Magento\Catalog\Model\Product\Gallery\ImagesConfigFactoryInterface $imagesConfigFactory
30-
* @param array $galleryImagesConfig
31-
* @param array $data
31+
* @param array $galleryImagesConfig
3232
*/
3333
public function __construct(
3434
\Magento\Catalog\Block\Product\Context $context,
@@ -43,9 +43,9 @@ public function __construct(
4343
$context,
4444
$arrayUtils,
4545
$jsonEncoder,
46+
$data,
4647
$imagesConfigFactory,
47-
$galleryImagesConfig,
48-
$data
48+
$galleryImagesConfig
4949
);
5050
$this->mediaHelper = $mediaHelper;
5151
}

0 commit comments

Comments
 (0)