10
10
use Magento \Framework \App \Config \ScopeConfigInterface ;
11
11
use Magento \Framework \App \ObjectManager ;
12
12
use Magento \Framework \DataObject ;
13
- use Magento \Framework \Serialize \Serializer \Json ;
13
+ use Magento \Framework \Serialize \Serializer \JsonHexTag ;
14
14
use Magento \Framework \View \Element \Block \ArgumentInterface ;
15
15
use Magento \Framework \Escaper ;
16
16
@@ -31,6 +31,11 @@ class Breadcrumbs extends DataObject implements ArgumentInterface
31
31
*/
32
32
private $ scopeConfig ;
33
33
34
+ /**
35
+ * @var JsonHexTag
36
+ */
37
+ private $ jsonSerializer ;
38
+
34
39
/**
35
40
* @var Escaper
36
41
*/
@@ -39,20 +44,21 @@ class Breadcrumbs extends DataObject implements ArgumentInterface
39
44
/**
40
45
* @param Data $catalogData
41
46
* @param ScopeConfigInterface $scopeConfig
42
- * @param Json|null $json
47
+ * @param JsonHexTag $jsonSerializer
43
48
* @param Escaper|null $escaper
44
49
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
45
50
*/
46
51
public function __construct (
47
52
Data $ catalogData ,
48
53
ScopeConfigInterface $ scopeConfig ,
49
- Json $ json = null ,
54
+ JsonHexTag $ jsonSerializer ,
50
55
Escaper $ escaper = null
51
56
) {
52
57
parent ::__construct ();
53
58
54
59
$ this ->catalogData = $ catalogData ;
55
60
$ this ->scopeConfig = $ scopeConfig ;
61
+ $ this ->jsonSerializer = $ jsonSerializer ;
56
62
$ this ->escaper = $ escaper ?: ObjectManager::getInstance ()->get (Escaper::class);
57
63
}
58
64
@@ -101,15 +107,14 @@ public function getProductName(): string
101
107
*/
102
108
public function getJsonConfigurationHtmlEscaped () : string
103
109
{
104
- return json_encode (
110
+ return $ this -> jsonSerializer -> serialize (
105
111
[
106
112
'breadcrumbs ' => [
107
113
'categoryUrlSuffix ' => $ this ->escaper ->escapeHtml ($ this ->getCategoryUrlSuffix ()),
108
114
'useCategoryPathInUrl ' => (int )$ this ->isCategoryUsedInProductUrl (),
109
115
'product ' => $ this ->escaper ->escapeHtml ($ this ->getProductName ())
110
116
]
111
- ],
112
- JSON_HEX_TAG
117
+ ]
113
118
);
114
119
}
115
120
0 commit comments