File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
app/code/Magento/CatalogGraphQl/Model/Category
lib/internal/Magento/Framework/Reflection Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -57,13 +57,19 @@ public function __construct(
57
57
*/
58
58
public function hydrateCategory (Category $ category , $ basicFieldsOnly = false ) : array
59
59
{
60
- if (!$ basicFieldsOnly ) {
61
- // initialize custom attributes (to be consequently included in subsequent getData call below)
62
- $ category ->getCustomAttributes ();
60
+ if ($ basicFieldsOnly ) {
61
+ $ categoryData = $ category ->getData ();
62
+ } else {
63
+ $ categoryData = $ this ->dataObjectProcessor ->buildOutputDataArray (
64
+ $ category ,
65
+ CategoryInterface::class,
66
+ [
67
+ 'getChildren ' ,
68
+ 'getExtensionAttributes ' ,
69
+ ]
70
+ );
63
71
}
64
72
65
- $ categoryData = $ category ->getData ();
66
-
67
73
$ categoryData ['id ' ] = $ category ->getId ();
68
74
$ categoryData ['uid ' ] = $ this ->uidEncoder ->encode ((string ) $ category ->getId ());
69
75
$ categoryData ['children ' ] = [];
Original file line number Diff line number Diff line change @@ -75,16 +75,21 @@ public function __construct(
75
75
*
76
76
* @param mixed $dataObject
77
77
* @param string $dataObjectType
78
+ * @param array $excludedMethods - list of methods to exclude from being called
78
79
* @return array
79
80
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
80
81
* @SuppressWarnings(PHPMD.NPathComplexity)
81
82
*/
82
- public function buildOutputDataArray ($ dataObject , $ dataObjectType )
83
+ public function buildOutputDataArray ($ dataObject , $ dataObjectType, array $ excludedMethods = [] )
83
84
{
84
85
$ methods = $ this ->methodsMapProcessor ->getMethodsMap ($ dataObjectType );
85
86
$ outputData = [];
86
87
87
88
foreach (array_keys ($ methods ) as $ methodName ) {
89
+ if (in_array ($ methodName , $ excludedMethods )) {
90
+ continue ;
91
+ }
92
+
88
93
if (!$ this ->methodsMapProcessor ->isMethodValidForDataField ($ dataObjectType , $ methodName )) {
89
94
continue ;
90
95
}
You can’t perform that action at this time.
0 commit comments