1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify |
5
|
|
|
* it under the terms of the GNU Lesser General Public License as published by |
6
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
7
|
|
|
* (at your option) any later version. |
8
|
|
|
* |
9
|
|
|
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful, |
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12
|
|
|
* GNU Lesser General Public License for more details. |
13
|
|
|
* |
14
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
15
|
|
|
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>. |
16
|
|
|
* |
17
|
|
|
* PHP version 5 |
18
|
|
|
* |
19
|
|
|
* @category Payone |
20
|
|
|
* @package Payone_Magento2_Plugin |
21
|
|
|
* @author FATCHIP GmbH <[email protected]> |
22
|
|
|
* @copyright 2003 - 2024 Payone GmbH |
23
|
|
|
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License |
24
|
|
|
* @link http://www.payone.de |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
namespace Payone\Core\Block\Paypal; |
28
|
|
|
|
29
|
|
|
use Magento\Framework\View\Element\Template; |
|
|
|
|
30
|
|
|
|
31
|
|
|
class Base extends Template implements \Magento\Catalog\Block\ShortcutInterface |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* Shortcut alias |
35
|
|
|
* |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $alias; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
protected $name; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var \Magento\Framework\Locale\ResolverInterface |
|
|
|
|
47
|
|
|
*/ |
48
|
|
|
protected $localeResolver; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Locale codes supported by misc images (marks, shortcuts etc) |
52
|
|
|
* |
53
|
|
|
* @var array |
54
|
|
|
*/ |
55
|
|
|
protected $aSupportedLocales = [ |
56
|
|
|
'de_DE', |
57
|
|
|
'en_AU', |
58
|
|
|
'en_GB', |
59
|
|
|
'en_US', |
60
|
|
|
'es_ES', |
61
|
|
|
'es_XC', |
62
|
|
|
'fr_FR', |
63
|
|
|
'fr_XC', |
64
|
|
|
'it_IT', |
65
|
|
|
'ja_JP', |
66
|
|
|
'nl_NL', |
67
|
|
|
'pl_PL', |
68
|
|
|
'zh_CN', |
69
|
|
|
'zh_XC', |
70
|
|
|
]; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Constructor |
74
|
|
|
* |
75
|
|
|
* @param \Magento\Framework\View\Element\Template\Context $context |
76
|
|
|
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver |
77
|
|
|
* @param array $data |
78
|
|
|
*/ |
79
|
|
|
public function __construct( |
80
|
|
|
\Magento\Framework\View\Element\Template\Context $context, |
|
|
|
|
81
|
|
|
\Magento\Framework\Locale\ResolverInterface $localeResolver, |
82
|
|
|
array $data = [] |
83
|
|
|
) { |
84
|
|
|
parent::__construct($context, $data); |
85
|
|
|
$this->localeResolver = $localeResolver; |
86
|
|
|
$this->setTemplate($this->sTemplate); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get shortcut alias |
91
|
|
|
* |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function getAlias() |
95
|
|
|
{ |
96
|
|
|
return $this->alias; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param string $sName |
101
|
|
|
* @return void |
102
|
|
|
*/ |
103
|
|
|
public function setName($sName) |
104
|
|
|
{ |
105
|
|
|
$this->name = $sName; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
|
|
public function getName() |
112
|
|
|
{ |
113
|
|
|
return $this->name; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return string |
119
|
|
|
*/ |
120
|
|
|
public function getButtonIdent() |
121
|
|
|
{ |
122
|
|
|
$sButtonIdent = "payone-paypal-button-container"; |
123
|
|
|
if (strpos($this->getName(), "checkout.cart.shortcut.buttons") !== false) { |
124
|
|
|
$sButtonIdent = "payone-paypal-button-basket"; |
125
|
|
|
} elseif (strpos($this->getName(), "shortcutbuttons") !== false) { |
126
|
|
|
$sButtonIdent = "payone-paypal-button-minibasket"; |
127
|
|
|
} |
128
|
|
|
return $sButtonIdent; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Check whether specified locale code is supported. Fallback to en_US |
133
|
|
|
* |
134
|
|
|
* @param string $sLocale |
135
|
|
|
* @return string |
136
|
|
|
*/ |
137
|
|
|
protected function getSupportedLocaleCode($sLocale = null) |
138
|
|
|
{ |
139
|
|
|
if (!$sLocale || !in_array($sLocale, $this->aSupportedLocales)) { |
140
|
|
|
return 'en_US'; |
141
|
|
|
} |
142
|
|
|
return $sLocale; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return string |
147
|
|
|
*/ |
148
|
|
|
protected function getLocale() |
149
|
|
|
{ |
150
|
|
|
$sCurrentLocal = $this->localeResolver->getLocale(); |
151
|
|
|
$sPayPalLocal = $this->getSupportedLocaleCode($sCurrentLocal); |
152
|
|
|
return $sPayPalLocal; |
153
|
|
|
} |
154
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths