7
7
namespace Magento \Eav \Model \Attribute \Data ;
8
8
9
9
use Magento \Framework \App \RequestInterface ;
10
+ use Magento \Framework \Locale \ResolverInterface ;
11
+ use Magento \Framework \Stdlib \DateTime \TimezoneInterface ;
12
+ use Magento \Framework \Stdlib \StringUtils ;
13
+ use Psr \Log \LoggerInterface ;
10
14
11
15
/**
12
16
* EAV Entity Attribute Text Data Model
@@ -21,20 +25,28 @@ class Text extends \Magento\Eav\Model\Attribute\Data\AbstractData
21
25
protected $ _string ;
22
26
23
27
/**
24
- * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
25
- * @param \Psr\Log\LoggerInterface $logger
26
- * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
27
- * @param \Magento\Framework\Stdlib\StringUtils $stringHelper
28
+ * @var array
29
+ */
30
+ private $ encodeAttributesByTypesList ;
31
+
32
+ /**
33
+ * @param TimezoneInterface $localeDate
34
+ * @param LoggerInterface $logger
35
+ * @param ResolverInterface $localeResolver
36
+ * @param StringUtils $stringHelper
37
+ * @param array $encodeAttributesByTypesList
28
38
* @codeCoverageIgnore
29
39
*/
30
40
public function __construct (
31
41
\Magento \Framework \Stdlib \DateTime \TimezoneInterface $ localeDate ,
32
42
\Psr \Log \LoggerInterface $ logger ,
33
43
\Magento \Framework \Locale \ResolverInterface $ localeResolver ,
34
- \Magento \Framework \Stdlib \StringUtils $ stringHelper
44
+ \Magento \Framework \Stdlib \StringUtils $ stringHelper ,
45
+ array $ encodeAttributesByTypesList = []
35
46
) {
36
47
parent ::__construct ($ localeDate , $ logger , $ localeResolver );
37
48
$ this ->_string = $ stringHelper ;
49
+ $ this ->encodeAttributesByTypesList = $ encodeAttributesByTypesList ;
38
50
}
39
51
40
52
/**
@@ -79,8 +91,10 @@ public function validateValue($value)
79
91
return $ errors ;
80
92
}
81
93
82
- // if string with diacritics encode it.
83
- $ value = $ this ->encodeDiacritics ($ value );
94
+ if (in_array ($ attribute ->getAttributeCode (), $ this ->encodeAttributesByTypesList [$ attribute ->getEntityType ()->getEntityTypeCode ()])) {
95
+ // if string with diacritics encode it.
96
+ $ value = $ this ->encodeDiacritics ($ value );
97
+ }
84
98
85
99
$ validateLengthResult = $ this ->validateLength ($ attribute , $ value );
86
100
$ errors = array_merge ($ errors , $ validateLengthResult );
0 commit comments