@@ -43,24 +43,34 @@ class TemplatePlugin
43
43
*/
44
44
private $ mathRandom ;
45
45
46
+ /**
47
+ * @var \Magento\Framework\Serialize\Serializer\Json
48
+ */
49
+ private $ json ;
50
+
46
51
/**
47
52
* @param \Psr\Log\LoggerInterface $logger
48
53
* @param \Magento\Framework\View\ConfigInterface $viewConfig
49
54
* @param \Magento\Framework\Math\Random $mathRandom
50
55
* @param \Magento\Framework\Escaper|null $escaper
56
+ * @param \Magento\Framework\Serialize\Serializer\Json|null $json
51
57
*/
52
58
public function __construct (
53
59
\Psr \Log \LoggerInterface $ logger ,
54
60
\Magento \Framework \View \ConfigInterface $ viewConfig ,
55
61
\Magento \Framework \Math \Random $ mathRandom ,
56
- \Magento \Framework \Escaper $ escaper = null
62
+ \Magento \Framework \Escaper $ escaper = null ,
63
+ \Magento \Framework \Serialize \Serializer \Json $ json = null
57
64
) {
58
65
$ this ->logger = $ logger ;
59
66
$ this ->viewConfig = $ viewConfig ;
60
67
$ this ->mathRandom = $ mathRandom ;
61
68
$ this ->escaper = $ escaper ?? \Magento \Framework \App \ObjectManager::getInstance ()->get (
62
69
\Magento \Framework \Escaper::class
63
70
);
71
+ $ this ->json = $ json ?? \Magento \Framework \App \ObjectManager::getInstance ()->get (
72
+ \Magento \Framework \Serialize \Serializer \Json::class
73
+ );
64
74
}
65
75
66
76
/**
@@ -269,8 +279,7 @@ private function generateBackgroundImageStyles(\DOMDocument $document) : void
269
279
$ backgroundImages = $ node ->attributes ->getNamedItem ('data-background-images ' );
270
280
if ($ backgroundImages ->nodeValue !== '' ) {
271
281
$ elementClass = uniqid ('background-image- ' );
272
- // phpcs:ignore Magento2.Functions.DiscouragedFunction
273
- $ images = json_decode (stripslashes ($ backgroundImages ->nodeValue ), true );
282
+ $ images = $ this ->json ->unserialize (stripslashes ($ backgroundImages ->nodeValue ));
274
283
if (count ($ images ) > 0 ) {
275
284
$ style = $ xpath ->document ->createElement (
276
285
'style ' ,
0 commit comments