14
14
use Magento \Framework \GraphQl \Query \Resolver \ContextInterface ;
15
15
use Magento \Framework \GraphQl \Query \Resolver \Value ;
16
16
use Magento \Framework \GraphQl \Query \ResolverInterface ;
17
+ use Magento \Framework \GraphQl \Query \Uid ;
17
18
use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
18
19
use Magento \GiftMessage \Api \OrderRepositoryInterface ;
19
20
use Psr \Log \LoggerInterface ;
@@ -33,16 +34,21 @@ class GiftMessage implements ResolverInterface
33
34
*/
34
35
private LoggerInterface $ logger ;
35
36
37
+ /** @var Uid */
38
+ private $ uidEncoder ;
39
+
36
40
/**
37
41
* @param OrderRepositoryInterface $orderRepository
38
42
* @param LoggerInterface|null $logger
39
43
*/
40
44
public function __construct (
41
45
OrderRepositoryInterface $ orderRepository ,
42
- LoggerInterface $ logger = null
46
+ LoggerInterface $ logger = null ,
47
+ Uid $ uidEncoder = null
43
48
) {
44
49
$ this ->orderRepository = $ orderRepository ;
45
50
$ this ->logger = $ logger ?? ObjectManager::getInstance ()->get (LoggerInterface::class);
51
+ $ this ->uidEncoder = $ uidEncoder ?? ObjectManager::getInstance ()->get (Uid::class);
46
52
}
47
53
48
54
/**
@@ -68,8 +74,8 @@ public function resolve(
68
74
if (!isset ($ value ['id ' ])) {
69
75
throw new GraphQlInputException (__ ('"id" value should be specified ' ));
70
76
}
71
- // phpcs:ignore Magento2.Functions.DiscouragedFunction
72
- $ orderId = ( int ) base64_decode ( $ value [ ' id ' ]) ?: ( int ) $ value ['id ' ];
77
+
78
+ $ orderId = $ this -> uidEncoder -> decode (( string ) $ value ['id ' ]) ;
73
79
74
80
try {
75
81
$ orderGiftMessage = $ this ->orderRepository ->get ($ orderId );
0 commit comments