Skip to content

Commit 43f4035

Browse files
committed
MC-16607: Fix Unrelated Static Test Failures
- fix tests failures
1 parent 1dc15ab commit 43f4035

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

app/code/Magento/PageBuilder/Plugin/Filter/TemplatePlugin.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,34 @@ class TemplatePlugin
4343
*/
4444
private $mathRandom;
4545

46+
/**
47+
* @var \Magento\Framework\Serialize\Serializer\Json
48+
*/
49+
private $json;
50+
4651
/**
4752
* @param \Psr\Log\LoggerInterface $logger
4853
* @param \Magento\Framework\View\ConfigInterface $viewConfig
4954
* @param \Magento\Framework\Math\Random $mathRandom
5055
* @param \Magento\Framework\Escaper|null $escaper
56+
* @param \Magento\Framework\Serialize\Serializer\Json|null $json
5157
*/
5258
public function __construct(
5359
\Psr\Log\LoggerInterface $logger,
5460
\Magento\Framework\View\ConfigInterface $viewConfig,
5561
\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
5764
) {
5865
$this->logger = $logger;
5966
$this->viewConfig = $viewConfig;
6067
$this->mathRandom = $mathRandom;
6168
$this->escaper = $escaper ?? \Magento\Framework\App\ObjectManager::getInstance()->get(
6269
\Magento\Framework\Escaper::class
6370
);
71+
$this->json = $json ?? \Magento\Framework\App\ObjectManager::getInstance()->get(
72+
\Magento\Framework\Serialize\Serializer\Json::class
73+
);
6474
}
6575

6676
/**
@@ -269,8 +279,7 @@ private function generateBackgroundImageStyles(\DOMDocument $document) : void
269279
$backgroundImages = $node->attributes->getNamedItem('data-background-images');
270280
if ($backgroundImages->nodeValue !== '') {
271281
$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));
274283
if (count($images) > 0) {
275284
$style = $xpath->document->createElement(
276285
'style',

0 commit comments

Comments
 (0)