Skip to content

Commit 2551f2a

Browse files
committed
Merge remote-tracking branch 'trigger/MC-41710' into MC-41701
2 parents 729765c + 90fca55 commit 2551f2a

File tree

4 files changed

+25
-33
lines changed

4 files changed

+25
-33
lines changed

app/code/Magento/Paypal/Block/PayLater/Banner.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class Banner extends Template
3535
/**
3636
* @param Template\Context $context
3737
* @param PayLaterConfig $payLaterConfig
38+
* @param SdkUrl $sdkUrl
3839
* @param array $data
3940
*/
4041
public function __construct(
@@ -105,11 +106,11 @@ private function getPayPalSdkUrl(): string
105106
/**
106107
* Retrieve style configuration
107108
*
108-
* @return array
109+
* @return string[]
109110
*/
110111
private function getStyleAttributesConfig(): array
111112
{
112-
return $this->payLaterConfig->getStyleConfig($this->placement);
113+
return $this->payLaterConfig->getSectionConfig($this->placement, PayLaterConfig::CONFIG_KEY_STYLES);
113114
}
114115

115116
/**
@@ -120,6 +121,8 @@ private function getStyleAttributesConfig(): array
120121
private function isEnabled(): bool
121122
{
122123
$enabled = $this->payLaterConfig->isEnabled($this->placement);
123-
return $enabled && $this->payLaterConfig->getPositionConfig($this->placement) == $this->position;
124+
return $enabled &&
125+
$this->payLaterConfig->getSectionConfig($this->placement, PayLaterConfig::CONFIG_KEY_POSITION) ===
126+
$this->position;
124127
}
125128
}

app/code/Magento/Paypal/Model/PayLaterConfig.php

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
*/
1515
class PayLaterConfig
1616
{
17+
/**
18+
* Configuration key for Styles settings
19+
*/
20+
const CONFIG_KEY_STYLES = 'styles';
21+
22+
/**
23+
* Configuration key for Position setting
24+
*/
25+
const CONFIG_KEY_POSITION = 'position';
26+
1727
/**
1828
* @var Config
1929
*/
@@ -41,28 +51,6 @@ public function __construct(
4151
$this->config = $config;
4252
}
4353

44-
/**
45-
* Get configured styles for specified page
46-
*
47-
* @param string $placement
48-
* @return array
49-
*/
50-
public function getStyleConfig(string $placement): array
51-
{
52-
return $this->getSectionConfig($placement, 'style') ?? [];
53-
}
54-
55-
/**
56-
* Get configured Banner position on specified page
57-
*
58-
* @param string $placement
59-
* @return string
60-
*/
61-
public function getPositionConfig(string $placement): string
62-
{
63-
return $this->getSectionConfig($placement, 'position') ?? '';
64-
}
65-
6654
/**
6755
* Check if Banner enabled for specified page
6856
*
@@ -96,9 +84,9 @@ private function isPPCreditEnabled()
9684
*
9785
* @param string $section
9886
* @param string $key
99-
* @return mixed
87+
* @return array|string|int
10088
*/
101-
private function getSectionConfig($section, $key)
89+
public function getSectionConfig(string $section, string $key)
10290
{
10391
if (!array_key_exists($section, $this->configData)) {
10492
$this->configData[$section] = [

app/code/Magento/Paypal/Plugin/CheckoutIndex.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Checkout\Controller\Index\Index;
1111
use Magento\Paypal\Model\Config;
12+
use Magento\Paypal\Model\ConfigFactory;
1213
use Magento\Paypal\Model\SdkUrl;
1314

1415
/**
@@ -25,19 +26,18 @@ class CheckoutIndex
2526
/**
2627
* @var Config
2728
*/
28-
private $config;
29+
private $configFactory;
2930

3031
/**
3132
* @param SdkUrl $sdkUrl
3233
* @param Config $config
3334
*/
3435
public function __construct(
3536
SdkUrl $sdkUrl,
36-
Config $config
37+
ConfigFactory $config
3738
) {
3839
$this->sdkUrl = $sdkUrl;
39-
$this->config = $config;
40-
$this->config->setMethod(Config::METHOD_EXPRESS);
40+
$this->configFactory = $config;
4141
}
4242

4343
/**
@@ -50,7 +50,8 @@ public function __construct(
5050
public function beforeExecute(Index $subject)
5151
{
5252
// Check If PP SmartButtons enabled
53-
if ((bool)(int) $this->config->getValue('in_context')) {
53+
$config = $this->configFactory->create()->setMethod(Config::METHOD_EXPRESS);
54+
if ((bool)(int) $config->getValue('in_context')) {
5455
$this->sdkUrl->setQueryParam('commit', 'true');
5556
}
5657

app/code/Magento/Paypal/Test/Unit/Model/SdkUrlTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function testGetConfig(
9494
string $intent,
9595
?string $disallowedFunding,
9696
bool $isPaypalGuestCheckoutEnabled,
97-
array $expected = []
97+
array $expected
9898
) {
9999
$this->localeResolverMock->method('getLocale')->willReturn($locale);
100100
$this->configMock->method('getValue')->willReturnMap(

0 commit comments

Comments
 (0)