Skip to content

Commit fe28e23

Browse files
committed
Refactor fields array population per code review
1 parent 13c45d1 commit fe28e23

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

app/code/Magento/Catalog/Model/Category/DataProvider.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Magento\Eav\Model\Entity\Type;
2323
use Magento\Framework\App\ObjectManager;
2424
use Magento\Framework\App\RequestInterface;
25+
use Magento\Framework\AuthorizationInterface;
2526
use Magento\Framework\Config\DataInterfaceFactory;
2627
use Magento\Framework\Exception\LocalizedException;
2728
use Magento\Framework\Exception\NoSuchEntityException;
@@ -33,7 +34,6 @@
3334
use Magento\Ui\Component\Form\Field;
3435
use Magento\Ui\DataProvider\EavValidationRules;
3536
use Magento\Ui\DataProvider\Modifier\PoolInterface;
36-
use Magento\Framework\AuthorizationInterface;
3737
use Magento\Ui\DataProvider\ModifierPoolDataProvider;
3838

3939
/**
@@ -671,22 +671,21 @@ protected function getFieldsMap()
671671
continue;
672672
}
673673

674-
$fieldsMap[$group] = [];
674+
$fields = [];
675675

676676
foreach ($node['children'] as $childName => $childNode) {
677677
if (!empty($childNode['children'])) {
678678
// <container/> nodes need special handling
679-
foreach ($childNode['children'] as $grandchildName => $grandchildNode) {
680-
$fieldsMap[$group][] = $grandchildName;
679+
foreach (array_keys($childNode['children']) as $grandchildName) {
680+
$fields[] = $grandchildName;
681681
}
682682
} else {
683-
$fieldsMap[$group][] = $childName;
683+
$fields[] = $childName;
684684
}
685685
}
686686

687-
// Remove empty groups
688-
if (empty($fieldsMap[$group])) {
689-
unset($fieldsMap[$group]);
687+
if (count($fields)) {
688+
$fieldsMap[$group] = $fields;
690689
}
691690
}
692691

0 commit comments

Comments
 (0)