Skip to content

Commit 10eff9c

Browse files
author
Oleksii Korshenko
authored
Merge pull request #658 from magento-fearless-kiwis/FearlessKiwis-MAGETWO-62020
Fixed issues: - MAGETWO-62020: Fix class constructors in a backward compatible way
2 parents f17a744 + fb975d3 commit 10eff9c

File tree

6 files changed

+68
-29
lines changed

6 files changed

+68
-29
lines changed

app/code/Magento/Customer/Model/Customer/DataProvider.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,18 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
9999
];
100100

101101
/**
102+
* DataProvider Constructor
103+
*
102104
* @param string $name
103105
* @param string $primaryFieldName
104106
* @param string $requestFieldName
105107
* @param EavValidationRules $eavValidationRules
106108
* @param CustomerCollectionFactory $customerCollectionFactory
107109
* @param Config $eavConfig
108110
* @param FilterPool $filterPool
109-
* @param FileProcessorFactory $fileProcessorFactory
110111
* @param array $meta
111112
* @param array $data
113+
* @param FileProcessorFactory|null $fileProcessorFactory
112114
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
113115
*/
114116
public function __construct(
@@ -119,23 +121,25 @@ public function __construct(
119121
CustomerCollectionFactory $customerCollectionFactory,
120122
Config $eavConfig,
121123
FilterPool $filterPool,
122-
FileProcessorFactory $fileProcessorFactory = null,
123124
array $meta = [],
124-
array $data = []
125+
array $data = [],
126+
FileProcessorFactory $fileProcessorFactory = null
125127
) {
126128
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
127129
$this->eavValidationRules = $eavValidationRules;
128130
$this->collection = $customerCollectionFactory->create();
129131
$this->collection->addAttributeToSelect('*');
130132
$this->eavConfig = $eavConfig;
131133
$this->filterPool = $filterPool;
132-
$this->fileProcessorFactory = $fileProcessorFactory ?: $this->getFileProcessorFactory();
133134
$this->meta['customer']['fields'] = $this->getAttributesMeta(
134135
$this->eavConfig->getEntityType('customer')
135136
);
136137
$this->meta['address']['fields'] = $this->getAttributesMeta(
137138
$this->eavConfig->getEntityType('customer_address')
138139
);
140+
$this->fileProcessorFactory = $fileProcessorFactory ?: ObjectManager::getInstance()->get(
141+
FileProcessorFactory::class
142+
);
139143
}
140144

141145
/**

app/code/Magento/Deploy/Model/Deployer.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ class Deployer
5050
* @param Version\StorageInterface $versionStorage
5151
* @param JsTranslationConfig $jsTranslationConfig
5252
* @param AlternativeSourceInterface[] $alternativeSources
53-
* @param DeployManagerFactory $deployManagerFactory
53+
* @param bool $isDryRun
54+
* @param DeployManagerFactory|null $deployManagerFactory
5455
* @param array $options
5556
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5657
*/
@@ -60,11 +61,14 @@ public function __construct(
6061
Version\StorageInterface $versionStorage,
6162
JsTranslationConfig $jsTranslationConfig,
6263
array $alternativeSources,
64+
$isDryRun = false,
6365
DeployManagerFactory $deployManagerFactory = null,
6466
$options = []
6567
) {
6668
$this->output = $output;
67-
$this->deployManagerFactory = $deployManagerFactory;
69+
$this->deployManagerFactory = $deployManagerFactory ?: ObjectManager::getInstance()->get(
70+
DeployManagerFactory::class
71+
);
6872
if (is_array($options)) {
6973
$this->options = $options;
7074
} else {

app/code/Magento/Sales/Model/InvoiceOrder.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
use Magento\Sales\Api\InvoiceOrderInterface;
1313
use Magento\Sales\Api\OrderRepositoryInterface;
1414
use Magento\Sales\Model\Order\Config as OrderConfig;
15+
use Magento\Sales\Model\Order\Invoice\InvoiceValidatorInterface;
1516
use Magento\Sales\Model\Order\Invoice\NotifierInterface;
1617
use Magento\Sales\Model\Order\InvoiceDocumentFactory;
1718
use Magento\Sales\Model\Order\InvoiceRepository;
1819
use Magento\Sales\Model\Order\OrderStateResolverInterface;
20+
use Magento\Sales\Model\Order\OrderValidatorInterface;
1921
use Magento\Sales\Model\Order\PaymentAdapterInterface;
2022
use Magento\Sales\Model\Order\Validation\InvoiceOrderInterface as InvoiceOrderValidator;
2123
use Psr\Log\LoggerInterface;
24+
use Magento\Framework\App\ObjectManager;
2225

2326
/**
2427
* Class InvoiceOrder
@@ -81,26 +84,31 @@ class InvoiceOrder implements InvoiceOrderInterface
8184
* @param ResourceConnection $resourceConnection
8285
* @param OrderRepositoryInterface $orderRepository
8386
* @param InvoiceDocumentFactory $invoiceDocumentFactory
87+
* @param InvoiceValidatorInterface $invoiceValidator
88+
* @param OrderValidatorInterface $orderValidator
8489
* @param PaymentAdapterInterface $paymentAdapter
8590
* @param OrderStateResolverInterface $orderStateResolver
8691
* @param OrderConfig $config
8792
* @param InvoiceRepository $invoiceRepository
88-
* @param InvoiceOrderValidator $invoiceOrderValidator
8993
* @param NotifierInterface $notifierInterface
9094
* @param LoggerInterface $logger
95+
* @param InvoiceOrderValidator|null $invoiceOrderValidator
9196
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
97+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
9298
*/
9399
public function __construct(
94100
ResourceConnection $resourceConnection,
95101
OrderRepositoryInterface $orderRepository,
96102
InvoiceDocumentFactory $invoiceDocumentFactory,
103+
InvoiceValidatorInterface $invoiceValidator,
104+
OrderValidatorInterface $orderValidator,
97105
PaymentAdapterInterface $paymentAdapter,
98106
OrderStateResolverInterface $orderStateResolver,
99107
OrderConfig $config,
100108
InvoiceRepository $invoiceRepository,
101-
InvoiceOrderValidator $invoiceOrderValidator,
102109
NotifierInterface $notifierInterface,
103-
LoggerInterface $logger
110+
LoggerInterface $logger,
111+
InvoiceOrderValidator $invoiceOrderValidator = null
104112
) {
105113
$this->resourceConnection = $resourceConnection;
106114
$this->orderRepository = $orderRepository;
@@ -109,9 +117,11 @@ public function __construct(
109117
$this->orderStateResolver = $orderStateResolver;
110118
$this->config = $config;
111119
$this->invoiceRepository = $invoiceRepository;
112-
$this->invoiceOrderValidator = $invoiceOrderValidator;
113120
$this->notifierInterface = $notifierInterface;
114121
$this->logger = $logger;
122+
$this->invoiceOrderValidator = $invoiceOrderValidator ?: ObjectManager::getInstance()->get(
123+
InvoiceOrderValidator::class
124+
);
115125
}
116126

117127
/**

app/code/Magento/Sales/Model/ShipOrder.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
use Magento\Sales\Api\ShipOrderInterface;
1212
use Magento\Sales\Model\Order\Config as OrderConfig;
1313
use Magento\Sales\Model\Order\OrderStateResolverInterface;
14+
use Magento\Sales\Model\Order\OrderValidatorInterface;
1415
use Magento\Sales\Model\Order\ShipmentDocumentFactory;
1516
use Magento\Sales\Model\Order\Shipment\NotifierInterface;
17+
use Magento\Sales\Model\Order\Shipment\ShipmentValidatorInterface;
1618
use Magento\Sales\Model\Order\Shipment\OrderRegistrarInterface;
1719
use Magento\Sales\Model\Order\Validation\ShipOrderInterface as ShipOrderValidator;
1820
use Psr\Log\LoggerInterface;
21+
use Magento\Framework\App\ObjectManager;
1922

2023
/**
2124
* Class ShipOrder
@@ -77,37 +80,46 @@ class ShipOrder implements ShipOrderInterface
7780
* @param ResourceConnection $resourceConnection
7881
* @param OrderRepositoryInterface $orderRepository
7982
* @param ShipmentDocumentFactory $shipmentDocumentFactory
83+
* @param ShipmentValidatorInterface $shipmentValidator
84+
* @param OrderValidatorInterface $orderValidator
8085
* @param OrderStateResolverInterface $orderStateResolver
8186
* @param OrderConfig $config
8287
* @param ShipmentRepositoryInterface $shipmentRepository
83-
* @param ShipOrderValidator $shipOrderValidator
8488
* @param NotifierInterface $notifierInterface
8589
* @param OrderRegistrarInterface $orderRegistrar
86-
* @param LoggerInterface $logger
90+
* @param LoggerInterface $logger,
91+
* @param ShipOrderValidator|null $shipOrderValidator
8792
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
93+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
8894
*/
8995
public function __construct(
9096
ResourceConnection $resourceConnection,
9197
OrderRepositoryInterface $orderRepository,
9298
ShipmentDocumentFactory $shipmentDocumentFactory,
99+
ShipmentValidatorInterface $shipmentValidator,
100+
OrderValidatorInterface $orderValidator,
93101
OrderStateResolverInterface $orderStateResolver,
94102
OrderConfig $config,
95103
ShipmentRepositoryInterface $shipmentRepository,
96-
ShipOrderValidator $shipOrderValidator,
97104
NotifierInterface $notifierInterface,
98105
OrderRegistrarInterface $orderRegistrar,
99-
LoggerInterface $logger
106+
LoggerInterface $logger,
107+
ShipOrderValidator $shipOrderValidator = null
100108
) {
101109
$this->resourceConnection = $resourceConnection;
102110
$this->orderRepository = $orderRepository;
103111
$this->shipmentDocumentFactory = $shipmentDocumentFactory;
112+
$this->shipmentValidator = $shipmentValidator;
113+
$this->orderValidator = $orderValidator;
104114
$this->orderStateResolver = $orderStateResolver;
105115
$this->config = $config;
106116
$this->shipmentRepository = $shipmentRepository;
107-
$this->shipOrderValidator = $shipOrderValidator;
108117
$this->notifierInterface = $notifierInterface;
109118
$this->logger = $logger;
110119
$this->orderRegistrar = $orderRegistrar;
120+
$this->shipOrderValidator = $shipOrderValidator ?: ObjectManager::getInstance()->get(
121+
ShipOrderValidator::class
122+
);
111123
}
112124

113125
/**

app/code/Magento/Sales/Model/Validator.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\Exception\LocalizedException;
99
use Magento\Framework\ObjectManagerInterface;
10+
use Magento\Framework\App\ObjectManager;
1011

1112
/**
1213
* Class Validator
@@ -29,14 +30,16 @@ class Validator
2930
* Validator constructor.
3031
*
3132
* @param ObjectManagerInterface $objectManager
32-
* @param ValidatorResultInterfaceFactory $validatorResult
33+
* @param ValidatorResultInterfaceFactory|null $validatorResult
3334
*/
3435
public function __construct(
3536
ObjectManagerInterface $objectManager,
36-
ValidatorResultInterfaceFactory $validatorResult
37+
ValidatorResultInterfaceFactory $validatorResult = null
3738
) {
3839
$this->objectManager = $objectManager;
39-
$this->validatorResultFactory = $validatorResult;
40+
$this->validatorResultFactory = $validatorResult ?: ObjectManager::getInstance()->get(
41+
ValidatorResultInterfaceFactory::class
42+
);
4043
}
4144

4245
/**

app/code/Magento/Sales/Test/Unit/Model/InvoiceOrderTest.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Magento\Sales\Model\ValidatorResultInterface;
2424
use Magento\Sales\Model\InvoiceOrder;
2525
use Psr\Log\LoggerInterface;
26+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
2627

2728
/**
2829
* Class InvoiceOrderTest
@@ -119,6 +120,8 @@ class InvoiceOrderTest extends \PHPUnit_Framework_TestCase
119120

120121
protected function setUp()
121122
{
123+
$objectManager = new ObjectManager($this);
124+
122125
$this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class)
123126
->disableOriginalConstructor()
124127
->getMock();
@@ -184,17 +187,20 @@ protected function setUp()
184187
->setMethods(['hasMessages', 'getMessages', 'addMessage'])
185188
->getMock();
186189

187-
$this->invoiceOrder = new InvoiceOrder(
188-
$this->resourceConnectionMock,
189-
$this->orderRepositoryMock,
190-
$this->invoiceDocumentFactoryMock,
191-
$this->paymentAdapterMock,
192-
$this->orderStateResolverMock,
193-
$this->configMock,
194-
$this->invoiceRepositoryMock,
195-
$this->invoiceOrderValidatorMock,
196-
$this->notifierInterfaceMock,
197-
$this->loggerMock
190+
$this->invoiceOrder = $objectManager->getObject(
191+
InvoiceOrder::class,
192+
[
193+
'resourceConnection' => $this->resourceConnectionMock,
194+
'orderRepository' => $this->orderRepositoryMock,
195+
'invoiceDocumentFactory' => $this->invoiceDocumentFactoryMock,
196+
'paymentAdapter' => $this->paymentAdapterMock,
197+
'orderStateResolver' => $this->orderStateResolverMock,
198+
'config' => $this->configMock,
199+
'invoiceRepository' => $this->invoiceRepositoryMock,
200+
'invoiceOrderValidator' => $this->invoiceOrderValidatorMock,
201+
'notifierInterface' => $this->notifierInterfaceMock,
202+
'logger' => $this->loggerMock
203+
]
198204
);
199205
}
200206

0 commit comments

Comments
 (0)