Magento 2 के यूआई पर्चा घटक विन्यास फाइल में, आप अक्सर एक देखेंगे itemका एक ही साथ विशेषता source- <item name="source" xsi:type="string">block</item>नीचे।
#File: vendor/magento/module-cms/view/adminhtml/ui_component/cms_block_form.xml
<field name="title">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Block Title</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">block</item>
<item name="sortOrder" xsi:type="number">20</item>
<item name="dataScope" xsi:type="string">title</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>
ये क्षेत्र किस लिए हैं? मैं पूछता हूं क्योंकि ऐसा लगता है कि वे आवश्यक नहीं हैं। उदाहरण के लिए, इस GitHub रिपॉजिटरी में मॉड्यूल एक कार्यशील UI घटक फॉर्म को कॉन्फ़िगर करता है, लेकिन इन name="source"वस्तुओं का उपयोग नहीं करता है ।
क्या किसी को पता है कि इन name="source"वस्तुओं के लिए क्या कर रहे हैं? मैं UI घटक मैकेनिक के बारे में जानता हूँ जो XML लेता है और x-magento-initJSON के रूप में इसकी पुष्टि करता है
"block_id": {
"type": "form.input",
"name": "block_id",
"dataScope": "block_id",
"config": {
"component": "Magento_Ui\/js\/form\/element\/abstract",
"template": "ui\/form\/field",
"visible": false,
"dataType": "text",
"formElement": "input",
"source": "block"
}
},
जिसे एक uiElementनॉकआउट व्यू मॉडल ऑब्जेक्ट में खिलाया गया है । हालाँकि, यह स्पष्ट नहीं है कि uiElementआधारित नॉकआउट दृश्य मॉडल ऑब्जेक्ट्स का नेस्टेड ट्री इन फ़ील्ड स्तर sourceफ़ील्ड का उपयोग कैसे करता है ।
अगर मैं uiElement's initModulesविधि को देखता हूं
initModules: function () {
_.each(this.modules, function (name, property) {
if (name) {
this[property] = this.requestModule(name);
}
}, this);
if (!_.isFunction(this.source)) {
this.source = registry.get(this.provider);
}
return this;
},
मैं देखता हूं कि ऑब्जेक्ट एक sourceसंपत्ति का संदर्भ देता है , और यदि इसका सेट नहीं होता है, तो providerएक स्ट्रिंग / कुंजी पहचानकर्ता के रूप में संपत्ति का उपयोग करते हुए किसी वस्तु के लिए रजिस्ट्री में पहुंच जाएगा । ऐसा लगता है कि इन sourceवस्तुओं के मूल्य का उपयोग नहीं किया जाता है। हालाँकि, यह संभव है कि वे PHP कोड या किसी अन्य जावास्क्रिप्ट कोड द्वारा उपयोग किए जाते हैं। इसलिए, मेरा सवाल।

sourceउन XML फ़ाइलों में क्या हो रहा है :)