Skip to content

Commit 87308cd

Browse files
committed
B2B-2464: Improve category children loading
- Revert optional parameter addition to avoid minor version change
1 parent 2c0b78d commit 87308cd

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

app/code/Magento/CatalogGraphQl/Model/Category/Hydrator.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,7 @@ public function hydrateCategory(Category $category, $basicFieldsOnly = false) :
6262
} else {
6363
$categoryData = $this->dataObjectProcessor->buildOutputDataArray(
6464
$category,
65-
CategoryInterface::class,
66-
[
67-
'getChildren',
68-
'getExtensionAttributes',
69-
]
65+
CategoryInterface::class
7066
);
7167
}
7268

lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,47 +46,56 @@ class DataObjectProcessor
4646
*/
4747
private $processors;
4848

49+
/**
50+
* @var array[]
51+
*/
52+
private $excludedMethodsClassMap;
53+
4954
/**
5055
* @param MethodsMap $methodsMapProcessor
5156
* @param TypeCaster $typeCaster
5257
* @param FieldNamer $fieldNamer
5358
* @param CustomAttributesProcessor $customAttributesProcessor
5459
* @param ExtensionAttributesProcessor $extensionAttributesProcessor
5560
* @param array $processors
61+
* @param array $excludedMethodsClassMap
5662
*/
5763
public function __construct(
5864
MethodsMap $methodsMapProcessor,
5965
TypeCaster $typeCaster,
6066
FieldNamer $fieldNamer,
6167
CustomAttributesProcessor $customAttributesProcessor,
6268
ExtensionAttributesProcessor $extensionAttributesProcessor,
63-
array $processors = []
69+
array $processors = [],
70+
array $excludedMethodsClassMap = []
6471
) {
6572
$this->methodsMapProcessor = $methodsMapProcessor;
6673
$this->typeCaster = $typeCaster;
6774
$this->fieldNamer = $fieldNamer;
6875
$this->extensionAttributesProcessor = $extensionAttributesProcessor;
6976
$this->customAttributesProcessor = $customAttributesProcessor;
7077
$this->processors = $processors;
78+
$this->excludedMethodsClassMap = $excludedMethodsClassMap;
7179
}
7280

7381
/**
7482
* Use class reflection on given data interface to build output data array
7583
*
7684
* @param mixed $dataObject
7785
* @param string $dataObjectType
78-
* @param array $excludedMethods - list of methods to exclude from being called
7986
* @return array
8087
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
8188
* @SuppressWarnings(PHPMD.NPathComplexity)
8289
*/
83-
public function buildOutputDataArray($dataObject, $dataObjectType, array $excludedMethods = [])
90+
public function buildOutputDataArray($dataObject, $dataObjectType)
8491
{
8592
$methods = $this->methodsMapProcessor->getMethodsMap($dataObjectType);
8693
$outputData = [];
8794

95+
$excludedMethodsForDataObjectType = $this->excludedMethodsClassMap[$dataObjectType] ?? [];
96+
8897
foreach (array_keys($methods) as $methodName) {
89-
if (in_array($methodName, $excludedMethods)) {
98+
if (in_array($methodName, $excludedMethodsForDataObjectType)) {
9099
continue;
91100
}
92101

0 commit comments

Comments
 (0)