33
44namespace Grasch \AdminUi \Plugin \Magento \Widget \Block \Adminhtml \Widget \Options ;
55
6- use Grasch \AdminUi \Model \Base64 ;
7- use Magento \Framework \Exception \LocalizedException ;
8- use Magento \Framework \Serialize \SerializerInterface ;
6+ use Grasch \AdminUi \Model \DecodeComponentValue ;
97use Magento \Widget \Block \Adminhtml \Widget \Options ;
10- use Psr \Log \LoggerInterface ;
118
129class DecodeComponentValues
1310{
1411 /**
15- * @var Base64
12+ * @var DecodeComponentValue
1613 */
17- private Base64 $ base64 ;
14+ private DecodeComponentValue $ decodeComponentValue ;
1815
1916 /**
20- * @var LoggerInterface
21- */
22- private LoggerInterface $ logger ;
23-
24- /**
25- * @var SerializerInterface
26- */
27- private SerializerInterface $ serializer ;
28-
29- /**
30- * @param Base64 $base64
31- * @param LoggerInterface $logger
32- * @param SerializerInterface $serializer
17+ * @param DecodeComponentValue $decodeComponentValue
3318 */
3419 public function __construct (
35- Base64 $ base64 ,
36- LoggerInterface $ logger ,
37- SerializerInterface $ serializer
20+ DecodeComponentValue $ decodeComponentValue
3821 ) {
39- $ this ->base64 = $ base64 ;
40- $ this ->logger = $ logger ;
41- $ this ->serializer = $ serializer ;
22+ $ this ->decodeComponentValue = $ decodeComponentValue ;
4223 }
4324
4425 /**
@@ -61,15 +42,7 @@ public function afterGetData(
6142 }
6243
6344 foreach ($ result as &$ value ) {
64- if (preg_match ('/encodedComponentsData\|.*/ ' , $ value )) {
65- $ value = preg_replace ('/encodedComponentsData\|/ ' , '' , $ value );
66- try {
67- $ value = $ this ->base64 ->decode ($ value );
68- $ value = $ this ->serializer ->unserialize ($ value );
69- } catch (LocalizedException $ e ) {
70- $ this ->logger ->error ($ e ->getMessage ());
71- };
72- }
45+ $ value = $ this ->decodeComponentValue ->execute ($ value );
7346 }
7447
7548 return $ result ;
0 commit comments