File tree Expand file tree Collapse file tree 4 files changed +25
-33
lines changed Expand file tree Collapse file tree 4 files changed +25
-33
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ class Banner extends Template
35
35
/**
36
36
* @param Template\Context $context
37
37
* @param PayLaterConfig $payLaterConfig
38
+ * @param SdkUrl $sdkUrl
38
39
* @param array $data
39
40
*/
40
41
public function __construct (
@@ -105,11 +106,11 @@ private function getPayPalSdkUrl(): string
105
106
/**
106
107
* Retrieve style configuration
107
108
*
108
- * @return array
109
+ * @return string[]
109
110
*/
110
111
private function getStyleAttributesConfig (): array
111
112
{
112
- return $ this ->payLaterConfig ->getStyleConfig ($ this ->placement );
113
+ return $ this ->payLaterConfig ->getSectionConfig ($ this ->placement , PayLaterConfig:: CONFIG_KEY_STYLES );
113
114
}
114
115
115
116
/**
@@ -120,6 +121,8 @@ private function getStyleAttributesConfig(): array
120
121
private function isEnabled (): bool
121
122
{
122
123
$ 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 ;
124
127
}
125
128
}
Original file line number Diff line number Diff line change 14
14
*/
15
15
class PayLaterConfig
16
16
{
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
+
17
27
/**
18
28
* @var Config
19
29
*/
@@ -41,28 +51,6 @@ public function __construct(
41
51
$ this ->config = $ config ;
42
52
}
43
53
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
-
66
54
/**
67
55
* Check if Banner enabled for specified page
68
56
*
@@ -96,9 +84,9 @@ private function isPPCreditEnabled()
96
84
*
97
85
* @param string $section
98
86
* @param string $key
99
- * @return mixed
87
+ * @return array|string|int
100
88
*/
101
- private function getSectionConfig ($ section , $ key )
89
+ public function getSectionConfig (string $ section , string $ key )
102
90
{
103
91
if (!array_key_exists ($ section , $ this ->configData )) {
104
92
$ this ->configData [$ section ] = [
Original file line number Diff line number Diff line change 9
9
10
10
use Magento \Checkout \Controller \Index \Index ;
11
11
use Magento \Paypal \Model \Config ;
12
+ use Magento \Paypal \Model \ConfigFactory ;
12
13
use Magento \Paypal \Model \SdkUrl ;
13
14
14
15
/**
@@ -25,19 +26,18 @@ class CheckoutIndex
25
26
/**
26
27
* @var Config
27
28
*/
28
- private $ config ;
29
+ private $ configFactory ;
29
30
30
31
/**
31
32
* @param SdkUrl $sdkUrl
32
33
* @param Config $config
33
34
*/
34
35
public function __construct (
35
36
SdkUrl $ sdkUrl ,
36
- Config $ config
37
+ ConfigFactory $ config
37
38
) {
38
39
$ this ->sdkUrl = $ sdkUrl ;
39
- $ this ->config = $ config ;
40
- $ this ->config ->setMethod (Config::METHOD_EXPRESS );
40
+ $ this ->configFactory = $ config ;
41
41
}
42
42
43
43
/**
@@ -50,7 +50,8 @@ public function __construct(
50
50
public function beforeExecute (Index $ subject )
51
51
{
52
52
// 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 ' )) {
54
55
$ this ->sdkUrl ->setQueryParam ('commit ' , 'true ' );
55
56
}
56
57
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ public function testGetConfig(
94
94
string $ intent ,
95
95
?string $ disallowedFunding ,
96
96
bool $ isPaypalGuestCheckoutEnabled ,
97
- array $ expected = []
97
+ array $ expected
98
98
) {
99
99
$ this ->localeResolverMock ->method ('getLocale ' )->willReturn ($ locale );
100
100
$ this ->configMock ->method ('getValue ' )->willReturnMap (
You can’t perform that action at this time.
0 commit comments