Skip to content

Commit dbf1ee9

Browse files
committed
Made code backward comaptible
1 parent 1fa9183 commit dbf1ee9

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

app/code/Magento/ConfigurableProduct/Model/LinkManagement.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,19 @@ class LinkManagement implements \Magento\ConfigurableProduct\Api\LinkManagementI
5252
*/
5353
private $attributeFactory;
5454

55+
/**
56+
* @var ProductRepository|mixed
57+
*/
5558
public \Magento\Catalog\Model\ProductRepository $mediaGallery;
59+
60+
/**
61+
* @var ProductAttributeMediaGalleryEntryInterfaceFactory|mixed
62+
*/
5663
public \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory $myModelFactory;
64+
65+
/**
66+
* @var array
67+
*/
5768
private array $images;
5869

5970
/**
@@ -73,17 +84,19 @@ public function __construct(
7384
\Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable $configurableType,
7485
\Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
7586
\Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory $attributeFactory = null,
76-
\Magento\Catalog\Model\ProductRepository $mediaGalleryProcessor,
77-
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory $myModelFactory
87+
\Magento\Catalog\Model\ProductRepository $mediaGalleryProcessor = null,
88+
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory $myModelFactory = null
7889
) {
7990
$this->productRepository = $productRepository;
8091
$this->productFactory = $productFactory;
8192
$this->configurableType = $configurableType;
8293
$this->dataObjectHelper = $dataObjectHelper;
8394
$this->attributeFactory = $attributeFactory ?: \Magento\Framework\App\ObjectManager::getInstance()
8495
->get(\Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory::class);
85-
$this->mediaGallery = $mediaGalleryProcessor;
86-
$this->myModelFactory = $myModelFactory;
96+
$this->mediaGallery = $mediaGalleryProcessor ?: \Magento\Framework\App\ObjectManager::getInstance()
97+
->get(\Magento\Catalog\Model\ProductRepository::class);
98+
$this->myModelFactory = $myModelFactory ?: \Magento\Framework\App\ObjectManager::getInstance()
99+
->get(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory::class);;
87100
}
88101

89102
/**

0 commit comments

Comments
 (0)