File tree Expand file tree Collapse file tree 5 files changed +24
-12
lines changed
app/code/Magento/GraphQlResolverCache/Model/Resolver/Result Expand file tree Collapse file tree 5 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -124,14 +124,20 @@ public function preProcessParentValue(array &$value): void
124
124
*/
125
125
private function hydrateData (&$ value )
126
126
{
127
- $ key = $ this ->defaultFlagGetter ->getFlagFromValue ($ value ) ?? null ;
128
- if ($ value && $ key ) {
129
- if (isset ($ this ->processedValues [$ key ])) {
130
- $ value = $ this ->processedValues [$ key ];
131
- } elseif (isset ($ this ->hydrators [$ key ]) && $ this ->hydrators [$ key ] instanceof HydratorInterface) {
132
- $ this ->hydrators [$ key ]->hydrate ($ value );
133
- $ this ->defaultFlagSetter ->unsetFlagFromValue ($ value );
134
- $ this ->processedValues [$ key ] = $ value ;
127
+ $ reference = $ this ->defaultFlagGetter ->getFlagFromValue ($ value ) ?? null ;
128
+ if (isset ($ reference ['cacheKey ' ]) && isset ($ reference ['index ' ])) {
129
+ $ cacheKey = $ reference ['cacheKey ' ];
130
+ $ index = $ reference ['index ' ];
131
+ if ($ value && $ cacheKey ) {
132
+ if (isset ($ this ->processedValues [$ cacheKey ][$ index ])) {
133
+ $ value = $ this ->processedValues [$ cacheKey ][$ index ];
134
+ } elseif (isset ($ this ->hydrators [$ cacheKey ])
135
+ && $ this ->hydrators [$ cacheKey ] instanceof HydratorInterface
136
+ ) {
137
+ $ this ->hydrators [$ cacheKey ]->hydrate ($ value );
138
+ $ this ->defaultFlagSetter ->unsetFlagFromValue ($ value );
139
+ $ this ->processedValues [$ cacheKey ][$ index ] = $ value ;
140
+ }
135
141
}
136
142
}
137
143
}
Original file line number Diff line number Diff line change @@ -18,5 +18,5 @@ interface FlagGetterInterface
18
18
* @param array $value
19
19
* @return string|null
20
20
*/
21
- public function getFlagFromValue (& $ value ): ?string ;
21
+ public function getFlagFromValue ($ value ): ?array ;
22
22
}
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class Generic implements FlagGetterInterface
17
17
/**
18
18
* @inheritdoc
19
19
*/
20
- public function getFlagFromValue (& $ value ): ?string
20
+ public function getFlagFromValue ($ value ): ?array
21
21
{
22
22
return $ value [ValueProcessorInterface::VALUE_HYDRATION_REFERENCE_KEY ] ?? null ;
23
23
}
Original file line number Diff line number Diff line change @@ -20,7 +20,10 @@ class Enumerable implements FlagSetterInterface
20
20
public function setFlagOnValue (&$ value , string $ flagValue ): void
21
21
{
22
22
foreach ($ value as $ key => $ data ) {
23
- $ value [$ key ][ValueProcessorInterface::VALUE_HYDRATION_REFERENCE_KEY ] = $ flagValue ;
23
+ $ value [$ key ][ValueProcessorInterface::VALUE_HYDRATION_REFERENCE_KEY ] = [
24
+ 'cacheKey ' => $ flagValue ,
25
+ 'index ' => $ key
26
+ ];
24
27
}
25
28
}
26
29
Original file line number Diff line number Diff line change @@ -19,7 +19,10 @@ class Generic implements FlagSetterInterface
19
19
*/
20
20
public function setFlagOnValue (&$ value , string $ flagValue ): void
21
21
{
22
- $ value [ValueProcessorInterface::VALUE_HYDRATION_REFERENCE_KEY ] = $ flagValue ;
22
+ $ value [ValueProcessorInterface::VALUE_HYDRATION_REFERENCE_KEY ] = [
23
+ 'cacheKey ' => $ flagValue ,
24
+ 'index ' => 0
25
+ ];
23
26
}
24
27
25
28
/**
You can’t perform that action at this time.
0 commit comments