Skip to content

Commit 05d7d0f

Browse files
authored
ENGCOM-6883: Reduce requirements for parameter in catalog product type factory #26821
2 parents 967115f + f0c64e5 commit 05d7d0f

File tree

1 file changed

+25
-31
lines changed
  • app/code/Magento/Catalog/Model/Product

1 file changed

+25
-31
lines changed

app/code/Magento/Catalog/Model/Product/Type.php

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,37 @@
66
namespace Magento\Catalog\Model\Product;
77

88
use Magento\Catalog\Model\Product;
9+
use Magento\Catalog\Model\Product\Type\Pool;
10+
use Magento\Catalog\Model\Product\Type\Price;
11+
use Magento\Catalog\Model\Product\Type\Price\Factory as PriceFactory;
12+
use Magento\Catalog\Model\Product\Type\Simple;
13+
use Magento\Catalog\Model\ProductTypes\ConfigInterface;
914
use Magento\Framework\Data\OptionSourceInterface;
15+
use Magento\Framework\Pricing\PriceInfo\Factory as PriceInfoFactory;
1016

1117
/**
1218
* Product type model
1319
*
20+
*
1421
* @api
1522
* @since 100.0.2
1623
*/
1724
class Type implements OptionSourceInterface
1825
{
19-
/**#@+
20-
* Available product types
21-
*/
2226
const TYPE_SIMPLE = 'simple';
2327

2428
const TYPE_BUNDLE = 'bundle';
2529

2630
const TYPE_VIRTUAL = 'virtual';
27-
/**#@-*/
2831

29-
/**
30-
* Default product type
31-
*/
3232
const DEFAULT_TYPE = 'simple';
3333

34-
/**
35-
* Default product type model
36-
*/
37-
const DEFAULT_TYPE_MODEL = \Magento\Catalog\Model\Product\Type\Simple::class;
34+
const DEFAULT_TYPE_MODEL = Simple::class;
3835

39-
/**
40-
* Default price model
41-
*/
42-
const DEFAULT_PRICE_MODEL = \Magento\Catalog\Model\Product\Type\Price::class;
36+
const DEFAULT_PRICE_MODEL = Price::class;
4337

4438
/**
45-
* @var \Magento\Catalog\Model\ProductTypes\ConfigInterface
39+
* @var ConfigInterface
4640
*/
4741
protected $_config;
4842

@@ -77,35 +71,35 @@ class Type implements OptionSourceInterface
7771
/**
7872
* Product type factory
7973
*
80-
* @var \Magento\Catalog\Model\Product\Type\Pool
74+
* @var Pool
8175
*/
8276
protected $_productTypePool;
8377

8478
/**
8579
* Price model factory
8680
*
87-
* @var \Magento\Catalog\Model\Product\Type\Price\Factory
81+
* @var PriceFactory
8882
*/
8983
protected $_priceFactory;
9084

9185
/**
92-
* @var \Magento\Framework\Pricing\PriceInfo\Factory
86+
* @var PriceInfoFactory
9387
*/
9488
protected $_priceInfoFactory;
9589

9690
/**
9791
* Construct
9892
*
99-
* @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $config
100-
* @param \Magento\Catalog\Model\Product\Type\Pool $productTypePool
101-
* @param \Magento\Catalog\Model\Product\Type\Price\Factory $priceFactory
102-
* @param \Magento\Framework\Pricing\PriceInfo\Factory $priceInfoFactory
93+
* @param ConfigInterface $config
94+
* @param Pool $productTypePool
95+
* @param PriceFactory $priceFactory
96+
* @param PriceInfoFactory $priceInfoFactory
10397
*/
10498
public function __construct(
105-
\Magento\Catalog\Model\ProductTypes\ConfigInterface $config,
106-
\Magento\Catalog\Model\Product\Type\Pool $productTypePool,
107-
\Magento\Catalog\Model\Product\Type\Price\Factory $priceFactory,
108-
\Magento\Framework\Pricing\PriceInfo\Factory $priceInfoFactory
99+
ConfigInterface $config,
100+
Pool $productTypePool,
101+
PriceFactory $priceFactory,
102+
PriceInfoFactory $priceInfoFactory
109103
) {
110104
$this->_config = $config;
111105
$this->_productTypePool = $productTypePool;
@@ -116,8 +110,8 @@ public function __construct(
116110
/**
117111
* Factory to product singleton product type instances
118112
*
119-
* @param \Magento\Catalog\Model\Product $product
120-
* @return \Magento\Catalog\Model\Product\Type\AbstractType
113+
* @param \Magento\Catalog\Api\Data\ProductInterface $product
114+
* @return \Magento\Catalog\Model\Product\Type\AbstractType
121115
*/
122116
public function factory($product)
123117
{
@@ -139,8 +133,8 @@ public function factory($product)
139133
/**
140134
* Product type price model factory
141135
*
142-
* @param string $productType
143-
* @return \Magento\Catalog\Model\Product\Type\Price
136+
* @param string $productType
137+
* @return \Magento\Catalog\Model\Product\Type\Price
144138
*/
145139
public function priceFactory($productType)
146140
{

0 commit comments

Comments
 (0)