什么是UI组件中的reverseMetadataMerge?


10

在查看UI组件的文档时,我注意到以下几点:

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

现在,大多数论据在做什么方面都非常不解自明,或者我已经知道了,但是做reverseMetadataMerge什么呢?

Answers:


11

您提到的设置用于 vendor/magento/framework/View/Element/UiComponentFactory.php

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

它将合并中已定义的元数据vendor/magento/module-customer/view/base/ui_component/customer_form.xml与数据提供者的构造函数中定义的其他一些元数据。

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;
}

对于文档,您的数据提供者是vendor/magento/module-customer/Model/Customer/DataProvider.php在构造函数内部

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

这增加了一些其他属性。对于客户,属性是下图中蓝色显示的属性

客户添加的属性

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.