Skip to content

Commit 397f87b

Browse files
author
Oleksii Korshenko
authored
Merge pull request #1199 from magento-engcom/develop-prs
Public Pull Requests #9306 #9902 #9928 #9925 #9915 #9391
2 parents 04b3b52 + b684944 commit 397f87b

File tree

19 files changed

+302
-91
lines changed

19 files changed

+302
-91
lines changed

app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,26 +315,35 @@ protected function getMultilineFieldConfig($attributeCode, array $attributeConfi
315315
*/
316316
protected function getDefaultValue($attributeCode)
317317
{
318+
if ($attributeCode === 'country_id') {
319+
return $this->directoryHelper->getDefaultCountry();
320+
}
321+
322+
$customer = $this->getCustomer();
323+
if ($customer === null) {
324+
return null;
325+
}
326+
327+
$attributeValue = null;
318328
switch ($attributeCode) {
329+
case 'prefix':
330+
$attributeValue = $customer->getPrefix();
331+
break;
319332
case 'firstname':
320-
if ($this->getCustomer()) {
321-
return $this->getCustomer()->getFirstname();
322-
}
333+
$attributeValue = $customer->getFirstname();
323334
break;
324335
case 'middlename':
325-
if ($this->getCustomer()) {
326-
return $this->getCustomer()->getMiddlename();
327-
}
336+
$attributeValue = $customer->getMiddlename();
328337
break;
329338
case 'lastname':
330-
if ($this->getCustomer()) {
331-
return $this->getCustomer()->getLastname();
332-
}
339+
$attributeValue = $customer->getLastname();
340+
break;
341+
case 'suffix':
342+
$attributeValue = $customer->getSuffix();
333343
break;
334-
case 'country_id':
335-
return $this->directoryHelper->getDefaultCountry();
336344
}
337-
return null;
345+
346+
return $attributeValue;
338347
}
339348

340349
/**

app/code/Magento/Deploy/Console/DeployStaticOptions.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ class DeployStaticOptions
131131
*/
132132
const CONTENT_VERSION = 'content-version';
133133

134+
/**
135+
* Key for refresh content version only mode
136+
*/
137+
const REFRESH_CONTENT_VERSION_ONLY = 'refresh-content-version-only';
138+
134139
/**
135140
* Deploy static command options list
136141
*
@@ -225,6 +230,13 @@ private function getBasicOptions()
225230
'Custom version of static content can be used if running deployment on multiple nodes '
226231
. 'to ensure that static content version is identical and caching works properly.'
227232
),
233+
new InputOption(
234+
self::REFRESH_CONTENT_VERSION_ONLY,
235+
null,
236+
InputOption::VALUE_NONE,
237+
'Refreshing the version of static content only can be used to refresh static content '
238+
. 'in browser cache and CDN cache.'
239+
),
228240
new InputArgument(
229241
self::LANGUAGES_ARGUMENT,
230242
InputArgument::IS_ARRAY,

app/code/Magento/Deploy/Service/DeployStaticContent.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ public function __construct(
7575
*/
7676
public function deploy(array $options)
7777
{
78+
$version = !empty($options[Options::CONTENT_VERSION]) && is_string($options[Options::CONTENT_VERSION])
79+
? $options[Options::CONTENT_VERSION]
80+
: (new \DateTime())->getTimestamp();
81+
$this->versionStorage->save($version);
82+
83+
if ($this->isRefreshContentVersionOnly($options)) {
84+
$this->logger->warning("New content version: " . $version);
85+
return;
86+
}
87+
7888
$queue = $this->queueFactory->create(
7989
[
8090
'logger' => $this->logger,
@@ -96,11 +106,6 @@ public function deploy(array $options)
96106
]
97107
);
98108

99-
$version = !empty($options[Options::CONTENT_VERSION]) && is_string($options[Options::CONTENT_VERSION])
100-
? $options[Options::CONTENT_VERSION]
101-
: (new \DateTime())->getTimestamp();
102-
$this->versionStorage->save($version);
103-
104109
$packages = $deployStrategy->deploy($options);
105110

106111
if ($options[Options::NO_JAVASCRIPT] !== true) {
@@ -135,4 +140,14 @@ private function getProcessesAmount(array $options)
135140
{
136141
return isset($options[Options::JOBS_AMOUNT]) ? (int)$options[Options::JOBS_AMOUNT] : 0;
137142
}
143+
144+
/**
145+
* @param array $options
146+
* @return bool
147+
*/
148+
private function isRefreshContentVersionOnly(array $options)
149+
{
150+
return isset($options[Options::REFRESH_CONTENT_VERSION_ONLY])
151+
&& $options[Options::REFRESH_CONTENT_VERSION_ONLY];
152+
}
138153
}

app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php

Lines changed: 64 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,18 @@ protected function setUp()
114114
public function testDeploy($options, $expectedContentVersion)
115115
{
116116
$package = $this->getMock(Package::class, [], [], '', false);
117-
$package->expects($this->exactly(1))->method('isVirtual')->willReturn(false);
118-
$package->expects($this->exactly(3))->method('getArea')->willReturn('area');
119-
$package->expects($this->exactly(3))->method('getTheme')->willReturn('theme');
120-
$package->expects($this->exactly(2))->method('getLocale')->willReturn('locale');
121-
122-
$packages = [
123-
'package' => $package
124-
];
117+
if ($options['refresh-content-version-only']) {
118+
$package->expects($this->never())->method('isVirtual');
119+
$package->expects($this->never())->method('getArea');
120+
$package->expects($this->never())->method('getTheme');
121+
$package->expects($this->never())->method('getLocale');
122+
} else {
123+
$package->expects($this->exactly(1))->method('isVirtual')->willReturn(false);
124+
$package->expects($this->exactly(3))->method('getArea')->willReturn('area');
125+
$package->expects($this->exactly(3))->method('getTheme')->willReturn('theme');
126+
$package->expects($this->exactly(2))->method('getLocale')->willReturn('locale');
127+
}
128+
$packages = ['package' => $package];
125129

126130
if ($expectedContentVersion) {
127131
$this->versionStorage->expects($this->once())->method('save')->with($expectedContentVersion);
@@ -132,20 +136,27 @@ public function testDeploy($options, $expectedContentVersion)
132136
$queue = $this->getMockBuilder(Queue::class)
133137
->disableOriginalConstructor()
134138
->getMockForAbstractClass();
135-
$this->queueFactory->expects($this->once())->method('create')->willReturn($queue);
139+
if ($options['refresh-content-version-only']) {
140+
$this->queueFactory->expects($this->never())->method('create');
141+
} else {
142+
$this->queueFactory->expects($this->once())->method('create')->willReturn($queue);
143+
}
136144

137145
$strategy = $this->getMockBuilder(CompactDeploy::class)
138146
->setMethods(['deploy'])
139147
->disableOriginalConstructor()
140148
->getMockForAbstractClass();
141-
$strategy->expects($this->once())->method('deploy')
142-
->with($options)
143-
->willReturn($packages);
144-
$this->deployStrategyFactory->expects($this->once())
145-
->method('create')
146-
->with('compact', ['queue' => $queue])
147-
->willReturn($strategy);
148-
149+
if ($options['refresh-content-version-only']) {
150+
$strategy->expects($this->never())->method('deploy');
151+
} else {
152+
$strategy->expects($this->once())->method('deploy')
153+
->with($options)
154+
->willReturn($packages);
155+
$this->deployStrategyFactory->expects($this->once())
156+
->method('create')
157+
->with('compact', ['queue' => $queue])
158+
->willReturn($strategy);
159+
}
149160
$deployPackageService = $this->getMockBuilder(DeployPackage::class)
150161
->disableOriginalConstructor()
151162
->getMockForAbstractClass();
@@ -166,34 +177,32 @@ public function testDeploy($options, $expectedContentVersion)
166177
->disableOriginalConstructor()
167178
->getMockForAbstractClass();
168179

169-
$this->objectManager->expects($this->exactly(4))
170-
->method('create')
171-
->withConsecutive(
172-
[DeployPackage::class, ['logger' => $this->logger]],
173-
[DeployRequireJsConfig::class, ['logger' => $this->logger]],
174-
[DeployTranslationsDictionary::class, ['logger' => $this->logger]],
175-
[Bundle::class, ['logger' => $this->logger]]
176-
)
177-
->willReturnOnConsecutiveCalls(
178-
$deployPackageService,
179-
$deployRjsConfig,
180-
$deployI18n,
181-
$deployBundle
182-
);
183-
184-
$this->objectManager->expects($this->exactly(1))
185-
->method('get')
186-
->withConsecutive(
187-
[MinifyTemplates::class]
188-
)
189-
->willReturnOnConsecutiveCalls(
190-
$minifyTemplates
191-
);
192-
193-
$this->assertEquals(
194-
null,
195-
$this->service->deploy($options)
196-
);
180+
if ($options['refresh-content-version-only']) {
181+
$this->objectManager->expects($this->never())->method('create');
182+
$this->objectManager->expects($this->never())->method('get');
183+
} else {
184+
$this->objectManager->expects($this->exactly(4))
185+
->method('create')
186+
->withConsecutive(
187+
[DeployPackage::class, ['logger' => $this->logger]],
188+
[DeployRequireJsConfig::class, ['logger' => $this->logger]],
189+
[DeployTranslationsDictionary::class, ['logger' => $this->logger]],
190+
[Bundle::class, ['logger' => $this->logger]]
191+
)
192+
->willReturnOnConsecutiveCalls(
193+
$deployPackageService,
194+
$deployRjsConfig,
195+
$deployI18n,
196+
$deployBundle
197+
);
198+
199+
$this->objectManager->expects($this->exactly(1))
200+
->method('get')
201+
->withConsecutive([MinifyTemplates::class])
202+
->willReturnOnConsecutiveCalls($minifyTemplates);
203+
}
204+
205+
$this->assertEquals(null, $this->service->deploy($options));
197206
}
198207

199208
public function deployDataProvider()
@@ -203,7 +212,8 @@ public function deployDataProvider()
203212
[
204213
'strategy' => 'compact',
205214
'no-javascript' => false,
206-
'no-html-minify' => false
215+
'no-html-minify' => false,
216+
'refresh-content-version-only' => false,
207217
],
208218
null // content version value should not be asserted in this case
209219
],
@@ -212,9 +222,17 @@ public function deployDataProvider()
212222
'strategy' => 'compact',
213223
'no-javascript' => false,
214224
'no-html-minify' => false,
225+
'refresh-content-version-only' => false,
215226
'content-version' => '123456',
216227
],
217228
'123456'
229+
],
230+
[
231+
[
232+
'refresh-content-version-only' => true,
233+
'content-version' => '654321',
234+
],
235+
'654321'
218236
]
219237
];
220238
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Vault\Api\Data;
8+
9+
/**
10+
* Interface PaymentTokenFactoryInterface
11+
* @api
12+
*/
13+
interface PaymentTokenFactoryInterface
14+
{
15+
/**
16+
* Payment Token types
17+
* @var string
18+
*/
19+
const TOKEN_TYPE_ACCOUNT = 'account';
20+
const TOKEN_TYPE_CREDIT_CARD = 'card';
21+
22+
/**
23+
* Create payment token entity
24+
* @param $type string|null
25+
* @return PaymentTokenInterface
26+
*/
27+
public function create($type = null);
28+
}

app/code/Magento/Vault/Api/Data/PaymentTokenInterfaceFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
/**
1010
* Interface PaymentTokenInterfaceFactory
11-
* @api
11+
* @deprecated
12+
* @see PaymentTokenFactoryInterface
1213
*/
1314
interface PaymentTokenInterfaceFactory
1415
{

app/code/Magento/Vault/Model/AbstractPaymentTokenFactory.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
use Magento\Framework\ObjectManagerInterface;
99
use Magento\Vault\Api\Data\PaymentTokenInterface;
1010
use Magento\Vault\Api\Data\PaymentTokenInterfaceFactory;
11+
use Magento\Vault\Api\Data\PaymentTokenFactoryInterface;
1112

1213
/**
1314
* Class AbstractPaymentTokenFactory
14-
* @api
15+
* @deprecated
16+
* @see PaymentTokenFactoryInterface
1517
*/
1618
abstract class AbstractPaymentTokenFactory implements PaymentTokenInterfaceFactory
1719
{
@@ -20,13 +22,26 @@ abstract class AbstractPaymentTokenFactory implements PaymentTokenInterfaceFacto
2022
*/
2123
private $objectManager;
2224

25+
/**
26+
* @var PaymentTokenFactoryInterface
27+
*/
28+
private $paymentTokenFactory;
29+
2330
/**
2431
* AccountPaymentTokenFactory constructor.
2532
* @param ObjectManagerInterface $objectManager
33+
* @param PaymentTokenFactoryInterface $paymentTokenFactory
2634
*/
27-
public function __construct(ObjectManagerInterface $objectManager)
28-
{
35+
public function __construct(
36+
ObjectManagerInterface $objectManager,
37+
PaymentTokenFactoryInterface $paymentTokenFactory = null
38+
) {
39+
if ($paymentTokenFactory === null) {
40+
$paymentTokenFactory = $objectManager->get(PaymentTokenFactoryInterface::class);
41+
}
42+
2943
$this->objectManager = $objectManager;
44+
$this->paymentTokenFactory = $paymentTokenFactory;
3045
}
3146

3247
/**
@@ -35,9 +50,6 @@ public function __construct(ObjectManagerInterface $objectManager)
3550
*/
3651
public function create()
3752
{
38-
/** @var PaymentTokenInterface $paymentToken */
39-
$paymentToken = $this->objectManager->create(PaymentTokenInterface::class);
40-
$paymentToken->setType($this->getType());
41-
return $paymentToken;
53+
return $this->paymentTokenFactory->create($this->getType());
4254
}
4355
}

app/code/Magento/Vault/Model/AccountPaymentTokenFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
/**
99
* Class AccountPaymentTokenFactory
10-
* @api
10+
* @deprecated
11+
* @see PaymentTokenFactoryInterface
1112
*/
1213
class AccountPaymentTokenFactory extends AbstractPaymentTokenFactory
1314
{

app/code/Magento/Vault/Model/CreditCardTokenFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
/**
99
* Class CreditCardTokenFactory
10-
* @api
10+
* @deprecated
11+
* @see PaymentTokenFactoryInterface
1112
*/
1213
class CreditCardTokenFactory extends AbstractPaymentTokenFactory
1314
{

0 commit comments

Comments
 (0)