@@ -53,9 +53,15 @@ class Save extends AbstractAction
53
53
54
54
/**
55
55
* @var DecoderInterface
56
+ * @deprecated
56
57
*/
57
58
protected $ jsonDecoder ;
58
59
60
+ /**
61
+ * @var \Magento\Framework\Serialize\Serializer\Json
62
+ */
63
+ private $ serializer ;
64
+
59
65
/**
60
66
* @param Context $context
61
67
* @param UiComponentFactory $factory
@@ -64,6 +70,8 @@ class Save extends AbstractAction
64
70
* @param BookmarkInterfaceFactory $bookmarkFactory
65
71
* @param UserContextInterface $userContext
66
72
* @param DecoderInterface $jsonDecoder
73
+ * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
74
+ * @throws \RuntimeException
67
75
*/
68
76
public function __construct (
69
77
Context $ context ,
@@ -72,20 +80,25 @@ public function __construct(
72
80
BookmarkManagementInterface $ bookmarkManagement ,
73
81
BookmarkInterfaceFactory $ bookmarkFactory ,
74
82
UserContextInterface $ userContext ,
75
- DecoderInterface $ jsonDecoder
83
+ DecoderInterface $ jsonDecoder ,
84
+ \Magento \Framework \Serialize \Serializer \Json $ serializer = null
76
85
) {
77
86
parent ::__construct ($ context , $ factory );
78
87
$ this ->bookmarkRepository = $ bookmarkRepository ;
79
88
$ this ->bookmarkManagement = $ bookmarkManagement ;
80
89
$ this ->bookmarkFactory = $ bookmarkFactory ;
81
90
$ this ->userContext = $ userContext ;
82
91
$ this ->jsonDecoder = $ jsonDecoder ;
92
+ $ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()
93
+ ->get (\Magento \Framework \Serialize \Serializer \Json::class);
83
94
}
84
95
85
96
/**
86
97
* Action for AJAX request
87
98
*
88
99
* @return void
100
+ * @throws \InvalidArgumentException
101
+ * @throws \LogicException
89
102
*/
90
103
public function execute ()
91
104
{
@@ -94,7 +107,7 @@ public function execute()
94
107
if (!$ jsonData ) {
95
108
throw new \InvalidArgumentException ('Invalid parameter "data" ' );
96
109
}
97
- $ data = $ this ->jsonDecoder -> decode ($ jsonData );
110
+ $ data = $ this ->serializer -> unserialize ($ jsonData );
98
111
$ action = key ($ data );
99
112
switch ($ action ) {
100
113
case self ::ACTIVE_IDENTIFIER :
0 commit comments