Skip to content

Commit fe448f7

Browse files
author
Karpenko, Oleksandr
committed
MAGETWO-52958: Better Semantic for UI Components
1 parent a7c0283 commit fe448f7

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
lines changed

app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@
424424
</settings>
425425
<container name="assign_products_container" sortOrder="160">
426426
<htmlContent name="html_content">
427-
<argument name="block" xsi:type="object">Magento\Catalog\Block\Adminhtml\Category\AssignProducts</argument>
427+
<block name="gallery" class="Magento\Catalog\Block\Adminhtml\Category\AssignProducts"/>
428428
</htmlContent>
429429
</container>
430430
</fieldset>

app/code/Magento/GoogleOptimizer/view/adminhtml/ui_component/category_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</settings>
1414
<container name="google_experiment_container" sortOrder="250">
1515
<htmlContent name="html_content">
16-
<argument name="block" xsi:type="object">Magento\GoogleOptimizer\Block\Adminhtml\Catalog\Category\Edit\Googleoptimizer</argument>
16+
<block name="googleoptimizer" class="Magento\GoogleOptimizer\Block\Adminhtml\Catalog\Category\Edit\Googleoptimizer"/>
1717
</htmlContent>
1818
</container>
1919
</fieldset>

app/code/Magento/GoogleOptimizer/view/adminhtml/ui_component/cms_page_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</settings>
1414
<container name="google_experiment_container" sortOrder="250">
1515
<htmlContent name="html_content">
16-
<argument name="block" xsi:type="object">Magento\GoogleOptimizer\Block\Adminhtml\Form\CmsPage</argument>
16+
<block name="googleOptimizerBlockAdminhtmlFormCmsPage" class="MagentoGoogleOptimizerBlockAdminhtmlFormCmsPage"/>
1717
</htmlContent>
1818
</container>
1919
</fieldset>

app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@
409409
</settings>
410410
<container name="conditions_apply_to" sortOrder="10">
411411
<htmlContent name="html_content">
412-
<argument name="block" xsi:type="object">Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Conditions</argument>
412+
<block name="sales_rule_conditions" class="Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Conditions" />
413413
</htmlContent>
414414
</container>
415415
</fieldset>
@@ -521,7 +521,7 @@
521521
</field>
522522
<container name="actions_apply_to" sortOrder="40">
523523
<htmlContent name="html_content">
524-
<argument name="block" xsi:type="object">Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Actions</argument>
524+
<block class="Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Actions"/>
525525
</htmlContent>
526526
</container>
527527
</fieldset>
@@ -544,7 +544,7 @@
544544
</field>
545545
<container name="store_view_labels" sortOrder="40">
546546
<htmlContent name="html_content">
547-
<argument name="block" xsi:type="object">Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Labels</argument>
547+
<block class="Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Labels"/>
548548
</htmlContent>
549549
</container>
550550
</fieldset>

dev/tests/integration/testsuite/Magento/Ui/Component/ConfigurationTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
5353
'argument[@name="data"]/item[@name="config"]/item[@name="multiple"]' => [
5454
'//*[@formElement="select"]',
5555
'//*[substring(@component, string-length(@component) - string-length("ui-group") +1) = "ui-group"]'
56-
],
57-
'argument[@name="block"]' => [
58-
'//*[@name="html_content"]'
5956
]
6057
];
6158

lib/internal/Magento/Framework/View/Layout/Reader/UiComponent.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ public function interpret(Context $readerContext, Element $currentElement)
9494
$scheduledStructure->setElementToIfconfigList($referenceName, $configPath, $this->scopeType);
9595
}
9696

97-
foreach ($this->getLayoutElementsFromUiConfiguration($referenceName) as $layoutElement) {
97+
$elements = [];
98+
$config = $this->uiConfigFactory->create(['componentName' => $referenceName])->get($referenceName);
99+
$this->getLayoutElementsFromUiConfiguration([$referenceName => $config], $elements);
100+
foreach ($elements as $layoutElement) {
98101
$layoutElement = simplexml_load_string(
99102
$layoutElement,
100103
Element::class
@@ -108,19 +111,20 @@ public function interpret(Context $readerContext, Element $currentElement)
108111
/**
109112
* Find layout elements in UI configuration for correct layout generation
110113
*
111-
* @param string $uiConfigName
112-
* @return array
114+
* @param array $config
115+
* @param array $elements
116+
* @return void
113117
*/
114-
private function getLayoutElementsFromUiConfiguration($uiConfigName)
118+
private function getLayoutElementsFromUiConfiguration(array $config, array &$elements = [])
115119
{
116-
$elements = [];
117-
$config = $this->uiConfigFactory->create(['componentName' => $uiConfigName])->get($uiConfigName);
118-
foreach ($config['children'] as $name => $data) {
120+
foreach ($config as $name => $data) {
119121
if (isset($data['arguments']['block']['layout'])) {
120-
$elements[$name] = $data['arguments']['block']['layout'];
122+
$elements[] = $data['arguments']['block']['layout'];
123+
}
124+
if (isset($data['children']) && !empty($data['children'])) {
125+
$this->getLayoutElementsFromUiConfiguration($data['children'], $elements);
121126
}
122127
}
123-
return $elements;
124128
}
125129

126130
/**

0 commit comments

Comments
 (0)