Skip to content

Commit 1c6a7a3

Browse files
committed
#CoreReview Fix backward compatibility
1 parent e6e6725 commit 1c6a7a3

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Catalog\Api\CategoryRepositoryInterface;
1010
use Magento\Catalog\Block\Product\AbstractProduct;
11+
use Magento\Catalog\Block\Product\Context;
1112
use Magento\Catalog\Block\Product\Widget\Html\Pager;
1213
use Magento\Catalog\Model\Product;
1314
use Magento\Catalog\Model\Product\Visibility;
@@ -16,7 +17,7 @@
1617
use Magento\Catalog\Pricing\Price\FinalPrice;
1718
use Magento\CatalogWidget\Model\Rule;
1819
use Magento\Framework\App\ActionInterface;
19-
use Magento\Framework\App\Http\Context;
20+
use Magento\Framework\App\Http\Context as HttpContext;
2021
use Magento\Framework\App\ObjectManager;
2122
use Magento\Framework\DataObject\IdentityInterface;
2223
use Magento\Framework\Exception\LocalizedException;
@@ -27,7 +28,7 @@
2728
use Magento\Framework\View\LayoutFactory;
2829
use Magento\Framework\View\LayoutInterface;
2930
use Magento\Rule\Model\Condition\Combine;
30-
use Magento\Rule\Model\Condition\Sql\Builder;
31+
use Magento\Rule\Model\Condition\Sql\Builder as SqlBuilder;
3132
use Magento\Widget\Block\BlockInterface;
3233
use Magento\Widget\Helper\Conditions;
3334

@@ -69,7 +70,7 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn
6970
protected $pager;
7071

7172
/**
72-
* @var Context
73+
* @var HttpContext
7374
*/
7475
protected $httpContext;
7576

@@ -88,7 +89,7 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn
8889
protected $productCollectionFactory;
8990

9091
/**
91-
* @var Builder
92+
* @var SqlBuilder
9293
*/
9394
protected $sqlBuilder;
9495

@@ -135,34 +136,34 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn
135136
private $categoryRepository;
136137

137138
/**
138-
* @param \Magento\Catalog\Block\Product\Context $context
139+
* @param Context $context
139140
* @param CollectionFactory $productCollectionFactory
140141
* @param Visibility $catalogProductVisibility
141-
* @param Context $httpContext
142-
* @param Builder $sqlBuilder
142+
* @param HttpContext $httpContext
143+
* @param SqlBuilder $sqlBuilder
143144
* @param Rule $rule
144145
* @param Conditions $conditionsHelper
145-
* @param CategoryRepositoryInterface $categoryRepository
146146
* @param array $data
147147
* @param Json|null $json
148148
* @param LayoutFactory|null $layoutFactory
149149
* @param EncoderInterface|null $urlEncoder
150+
* @param CategoryRepositoryInterface|null $categoryRepository
150151
*
151152
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
152153
*/
153154
public function __construct(
154-
\Magento\Catalog\Block\Product\Context $context,
155+
Context $context,
155156
CollectionFactory $productCollectionFactory,
156157
Visibility $catalogProductVisibility,
157-
Context $httpContext,
158-
Builder $sqlBuilder,
158+
HttpContext $httpContext,
159+
SqlBuilder $sqlBuilder,
159160
Rule $rule,
160161
Conditions $conditionsHelper,
161-
CategoryRepositoryInterface $categoryRepository,
162162
array $data = [],
163163
Json $json = null,
164164
LayoutFactory $layoutFactory = null,
165-
EncoderInterface $urlEncoder = null
165+
EncoderInterface $urlEncoder = null,
166+
CategoryRepositoryInterface $categoryRepository = null
166167
) {
167168
$this->productCollectionFactory = $productCollectionFactory;
168169
$this->catalogProductVisibility = $catalogProductVisibility;
@@ -173,7 +174,8 @@ public function __construct(
173174
$this->json = $json ?: ObjectManager::getInstance()->get(Json::class);
174175
$this->layoutFactory = $layoutFactory ?: ObjectManager::getInstance()->get(LayoutFactory::class);
175176
$this->urlEncoder = $urlEncoder ?: ObjectManager::getInstance()->get(EncoderInterface::class);
176-
$this->categoryRepository = $categoryRepository;
177+
$this->categoryRepository = $categoryRepository ?? ObjectManager::getInstance()
178+
->get(CategoryRepositoryInterface::class);
177179
parent::__construct(
178180
$context,
179181
$data

0 commit comments

Comments
 (0)