8
8
9
9
namespace Magento \UpwardConnector \Model \Computed ;
10
10
11
+ use Magento \Framework \GraphQl \Query \Uid ;
11
12
use Magento \Framework \Serialize \Serializer \Json ;
12
13
use Magento \Store \Model \StoreManagerInterface ;
13
14
use Magento \Upward \Definition ;
@@ -30,6 +31,9 @@ class PageInfo implements ComputedInterface
30
31
/** @var \Magento\UrlRewriteGraphQl\Model\DataProvider\EntityDataProviderComposite */
31
32
private $ entityDataProviderComposite ;
32
33
34
+ /** @var \Magento\Framework\GraphQl\Query\Uid */
35
+ private $ uid ;
36
+
33
37
/**
34
38
* @param \Magento\UpwardConnector\Model\PageType $pageTypeResolver
35
39
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
@@ -40,12 +44,14 @@ public function __construct(
40
44
PageType $ pageTypeResolver ,
41
45
StoreManagerInterface $ storeManager ,
42
46
Json $ json ,
43
- EntityDataProviderComposite $ entityDataProviderComposite
47
+ EntityDataProviderComposite $ entityDataProviderComposite ,
48
+ Uid $ uid
44
49
) {
45
50
$ this ->pageTypeResolver = $ pageTypeResolver ;
46
51
$ this ->storeManager = $ storeManager ;
47
52
$ this ->json = $ json ;
48
53
$ this ->entityDataProviderComposite = $ entityDataProviderComposite ;
54
+ $ this ->uid = $ uid ;
49
55
}
50
56
51
57
/**
@@ -131,7 +137,7 @@ public function isPageInfoComplete($pageInfo, $additionalMap): bool
131
137
{
132
138
$ pageInfoHasAllData = true ;
133
139
if ($ additionalMap ) {
134
- foreach ($ additionalMap as $ key ) {
140
+ foreach ($ additionalMap as $ key ) {
135
141
if (!isset ($ pageInfo [$ key ])) {
136
142
$ pageInfoHasAllData = false ;
137
143
@@ -145,7 +151,8 @@ public function isPageInfoComplete($pageInfo, $additionalMap): bool
145
151
146
152
/**
147
153
* @param array $data
148
- * @param array{type: string, fetch: string}|bool $map
154
+ * @param array|bool $map
155
+ * @param string $type
149
156
*
150
157
* @return array
151
158
*/
@@ -156,7 +163,7 @@ public function filterData($data, $map, $type)
156
163
}
157
164
158
165
$ result = [];
159
- foreach ($ map as $ valueKey ) {
166
+ foreach ($ map as $ valueKey ) {
160
167
$ result [$ valueKey ] = $ this ->getEntityValue ($ data , $ valueKey , $ type );
161
168
}
162
169
@@ -184,6 +191,10 @@ public function getEntityValue(array $data, string $key, string $type)
184
191
return $ data ['id ' ] ?? $ data ['entity_id ' ];
185
192
}
186
193
194
+ if ($ key === 'uid ' && (isset ($ data ['id ' ]) || isset ($ data ['entity_id ' ]))) {
195
+ return $ this ->uid ->encode ($ data ['id ' ] ?? $ data ['entity_id ' ]);
196
+ }
197
+
187
198
return $ data [$ key ] ?? null ;
188
199
}
189
200
}
0 commit comments