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(
5757 */
5858 public function hydrateCategory (Category $ category , $ basicFieldsOnly = false ) : array
5959 {
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+ );
6371 }
6472
65- $ categoryData = $ category ->getData ();
66-
6773 $ categoryData ['id ' ] = $ category ->getId ();
6874 $ categoryData ['uid ' ] = $ this ->uidEncoder ->encode ((string ) $ category ->getId ());
6975 $ categoryData ['children ' ] = [];
Original file line number Diff line number Diff line change @@ -75,16 +75,21 @@ public function __construct(
7575 *
7676 * @param mixed $dataObject
7777 * @param string $dataObjectType
78+ * @param array $excludedMethods - list of methods to exclude from being called
7879 * @return array
7980 * @SuppressWarnings(PHPMD.CyclomaticComplexity)
8081 * @SuppressWarnings(PHPMD.NPathComplexity)
8182 */
82- public function buildOutputDataArray ($ dataObject , $ dataObjectType )
83+ public function buildOutputDataArray ($ dataObject , $ dataObjectType, array $ excludedMethods = [] )
8384 {
8485 $ methods = $ this ->methodsMapProcessor ->getMethodsMap ($ dataObjectType );
8586 $ outputData = [];
8687
8788 foreach (array_keys ($ methods ) as $ methodName ) {
89+ if (in_array ($ methodName , $ excludedMethods )) {
90+ continue ;
91+ }
92+
8893 if (!$ this ->methodsMapProcessor ->isMethodValidForDataField ($ dataObjectType , $ methodName )) {
8994 continue ;
9095 }
You can’t perform that action at this time.
0 commit comments