Skip to content

Commit 91f8f88

Browse files
committed
adding backward compatibility in constructor
1 parent 8f491d3 commit 91f8f88

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

app/code/Magento/Wishlist/Model/Wishlist.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ class Wishlist extends AbstractModel implements IdentityInterface
175175
* @param Random $mathRandom
176176
* @param DateTime $dateTime
177177
* @param ProductRepositoryInterface $productRepository
178-
* @param StockItemRepository $stockItemRepository
179-
* @param ScopeConfigInterface|null $scopeConfig
180178
* @param bool $useCurrentWebsite
181179
* @param array $data
182180
* @param Json|null $serializer
181+
* @param StockItemRepository|null $stockItemRepository
182+
* @param ScopeConfigInterface|null $scopeConfig
183183
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
184184
*/
185185
public function __construct(
@@ -197,11 +197,11 @@ public function __construct(
197197
Random $mathRandom,
198198
DateTime $dateTime,
199199
ProductRepositoryInterface $productRepository,
200-
StockItemRepository $stockItemRepository,
201-
ScopeConfigInterface $scopeConfig = null,
202200
$useCurrentWebsite = true,
203201
array $data = [],
204-
Json $serializer = null
202+
Json $serializer = null,
203+
StockItemRepository $stockItemRepository = null,
204+
ScopeConfigInterface $scopeConfig = null
205205
) {
206206
$this->_useCurrentWebsite = $useCurrentWebsite;
207207
$this->_catalogProduct = $catalogProduct;
@@ -216,7 +216,9 @@ public function __construct(
216216
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
217217
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
218218
$this->productRepository = $productRepository;
219-
$this->stockItemRepository = $stockItemRepository;
219+
$this->stockItemRepository = $stockItemRepository ?: ObjectManager::getInstance()->get(
220+
StockItemRepository::class
221+
);
220222
$this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()->get(ScopeConfigInterface::class);
221223
}
222224

0 commit comments

Comments
 (0)