7
7
8
8
namespace Magento \Paypal \Model ;
9
9
10
- use Magento \Framework \App \Config \ScopeConfigInterface ;
11
-
12
10
/**
13
11
* Provides configuration values for PayPal PayLater Banners
14
12
*/
@@ -34,25 +32,17 @@ class PayLaterConfig
34
32
*/
35
33
private $ config ;
36
34
37
- /**
38
- * @var ScopeConfigInterface
39
- */
40
- private $ scopeConfig ;
41
-
42
35
/**
43
36
* @var array
44
37
*/
45
38
private $ configData = [];
46
39
47
40
/**
48
- * @param ScopeConfigInterface $scopeConfig
49
41
* @param ConfigFactory $configFactory
50
42
*/
51
43
public function __construct (
52
- ScopeConfigInterface $ scopeConfig ,
53
44
ConfigFactory $ configFactory
54
45
) {
55
- $ this ->scopeConfig = $ scopeConfig ;
56
46
$ this ->config = $ configFactory ->create ();
57
47
}
58
48
@@ -76,9 +66,9 @@ public function isEnabled(string $placement): bool
76
66
/**
77
67
* Check that PayPal Credit enabled with any PayPal express method
78
68
*
79
- * @return
69
+ * @return bool
80
70
*/
81
- private function isPPCreditEnabled ()
71
+ private function isPPCreditEnabled (): bool
82
72
{
83
73
$ isEnabled = false ;
84
74
if ($ this ->config ->setMethod (Config::METHOD_EXPRESS )->getValue ('in_context ' )) {
@@ -106,35 +96,47 @@ public function getSectionConfig(string $section, string $key)
106
96
$ this ->configData [$ section ] = [
107
97
'display ' => (boolean )$ this ->config ->getPayLaterConfigValue ("$ {sectionName}_display " ),
108
98
'position ' => $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_position " ),
109
- 'style ' => [
110
- 'data-pp-style-layout ' => $ this ->config ->getPayLaterConfigValue (
111
- "$ {sectionName}_stylelayout "
112
- ),
113
- 'data-pp-style-logo-type ' => $ this ->config ->getPayLaterConfigValue (
114
- "$ {sectionName}_logotype "
115
- ),
116
- 'data-pp-style-logo-position ' => $ this ->config ->getPayLaterConfigValue (
117
- "$ {sectionName}_logoposition "
118
- ),
119
- 'data-pp-style-text-color ' => $ this ->config ->getPayLaterConfigValue (
120
- "$ {sectionName}_textcolor "
121
- ),
122
- 'data-pp-style-text-size ' => $ this ->config ->getPayLaterConfigValue (
123
- "$ {sectionName}_textsize "
124
- ),
125
- 'data-pp-style-color ' => $ this ->config ->getPayLaterConfigValue (
126
- "$ {sectionName}_color "
127
- ),
128
- 'data-pp-style-ratio ' => $ this ->config ->getPayLaterConfigValue (
129
- "$ {sectionName}_ratio "
130
- )
131
- ]
99
+ 'style ' => $ this ->getConfigStyles ($ sectionName )
132
100
];
133
101
}
134
102
135
103
return $ this ->configData [$ section ][$ key ];
136
104
}
137
105
106
+ /**
107
+ * Get only the config styles that are needed
108
+ *
109
+ * @param string $sectionName
110
+ * @return array
111
+ */
112
+ private function getConfigStyles (string $ sectionName ): array
113
+ {
114
+ $ logoType = $ logoPosition = $ textColor = $ textSize = null ;
115
+ $ color = $ ratio = null ;
116
+ $ styleLayout = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_stylelayout " );
117
+ if ($ styleLayout === 'text ' ) {
118
+ $ logoType = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_logotype " );
119
+ if ($ logoType === 'primary ' || $ logoType === 'alternative ' ) {
120
+ $ logoPosition = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_logoposition " );
121
+ }
122
+ $ textColor = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_textcolor " );
123
+ $ textSize = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_textsize " );
124
+ } elseif ($ styleLayout === 'flex ' ) {
125
+ $ color = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_color " );
126
+ $ ratio = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_ratio " );
127
+ }
128
+
129
+ return [
130
+ 'data-pp-style-layout ' => $ styleLayout ,
131
+ 'data-pp-style-logo-type ' => $ logoType ,
132
+ 'data-pp-style-logo-position ' => $ logoPosition ,
133
+ 'data-pp-style-text-color ' => $ textColor ,
134
+ 'data-pp-style-text-size ' => $ textSize ,
135
+ 'data-pp-style-color ' => $ color ,
136
+ 'data-pp-style-ratio ' => $ ratio
137
+ ];
138
+ }
139
+
138
140
/**
139
141
* Check if billing agreement is enabled
140
142
*
0 commit comments