Skip to content

Commit e1dbaf3

Browse files
Merge pull request #109 from magento-borg/MC-15057-ObjectManager-To-Constructor
Mc 15057 object manager to constructor
2 parents 93e0816 + 02c61cc commit e1dbaf3

File tree

1 file changed

+29
-10
lines changed
  • app/code/Magento/DownloadableSampleData/Model/Product

1 file changed

+29
-10
lines changed

app/code/Magento/DownloadableSampleData/Model/Product/Converter.php

+29-10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,35 @@ class Converter extends \Magento\CatalogSampleData\Model\Product\Converter
2424
*/
2525
private $filesystem;
2626

27+
public function __construct(
28+
\Magento\Catalog\Model\Category\TreeFactory $categoryTreeFactory,
29+
\Magento\Catalog\Model\ResourceModel\Category\TreeFactory $categoryResourceTreeFactory,
30+
\Magento\Eav\Model\Config $eavConfig,
31+
\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $categoryCollectionFactory,
32+
\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $attributeCollectionFactory,
33+
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory,
34+
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
35+
\Magento\Downloadable\Api\Data\File\ContentInterfaceFactory $fileContentFactory = null,
36+
Filesystem $filesystem = null
37+
) {
38+
parent::__construct(
39+
$categoryTreeFactory,
40+
$categoryResourceTreeFactory,
41+
$eavConfig,
42+
$categoryCollectionFactory,
43+
$attributeCollectionFactory,
44+
$attrOptionCollectionFactory,
45+
$productCollectionFactory
46+
);
47+
$this->fileContentFactory = $fileContentFactory ?: ObjectManager::getInstance()->get(
48+
\Magento\Downloadable\Api\Data\File\ContentInterfaceFactory::class
49+
);
50+
$this->filesystem = $filesystem ?: ObjectManager::getInstance()->get(
51+
Filesystem::class
52+
);
53+
}
54+
55+
2756
/**
2857
* Get downloadable data from array
2958
*
@@ -159,11 +188,6 @@ public function getSamplesInfo()
159188
*/
160189
private function getFileContent()
161190
{
162-
if (!$this->fileContentFactory) {
163-
$this->fileContentFactory = ObjectManager::getInstance()->create(
164-
\Magento\Downloadable\Api\Data\File\ContentInterfaceFactory::class
165-
);
166-
}
167191
return $this->fileContentFactory->create();
168192
}
169193

@@ -173,11 +197,6 @@ private function getFileContent()
173197
*/
174198
private function getFilesystem()
175199
{
176-
if (!$this->filesystem) {
177-
$this->filesystem = ObjectManager::getInstance()->create(
178-
Filesystem::class
179-
);
180-
}
181200
return $this->filesystem;
182201
}
183202
}

0 commit comments

Comments
 (0)