11

When I look at the documentation of UI Components, I notice the following:

<item name="reverseMetadataMerge" xsi:type="boolean">true</item>

Now, most arguments are pretty self-explaining in what they do, or I already know it, but what does reverseMetadataMerge do?

1 Answer 1

12

The setting you mention is used in vendor/magento/framework/View/Element/UiComponentFactory.php

 $reverseMerge = isset($componentArguments['data']['reverseMetadataMerge'])
            && $componentArguments['data']['reverseMetadataMerge'];
        $bundleComponents = $this->mergeMetadata($identifier, $bundleComponents, $reverseMerge);

this will merge the already defined metadata in the vendor/magento/module-customer/view/base/ui_component/customer_form.xml with some other metadata defined in the constructor of the data provider.

protected function mergeMetadata($identifier, array $bundleComponents, $reverseMerge = false)
{
    $dataProvider = $this->getDataProvider($identifier, $bundleComponents);
    if ($dataProvider instanceof DataProviderInterface) {
        $metadata = [
            $identifier => [
                'children' => $dataProvider->getMeta(),
            ],
        ];
        $bundleComponents = $this->mergeMetadataItem($bundleComponents, $metadata, $reverseMerge);
    }

    return $bundleComponents;
}

In the case of the documentation your data provider is vendor/magento/module-customer/Model/Customer/DataProvider.php that inside the constructor has

 $this->meta['customer']['children'] = $this->getAttributesMeta(
        $this->eavConfig->getEntityType('customer')
    );
    $this->meta['address']['children'] = $this->getAttributesMeta(
        $this->eavConfig->getEntityType('customer_address')
    );

that adds some other attributes. In the case of the customer the attributes are the ones shown in blue color in the following image

customer added attributes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.