From fe448f7affd214dab54ca17e25a646cd9b51bfa3 Mon Sep 17 00:00:00 2001 From: "Karpenko, Oleksandr" Date: Mon, 10 Apr 2017 20:02:06 +0300 Subject: [PATCH 1/5] MAGETWO-52958: Better Semantic for UI Components --- .../adminhtml/ui_component/category_form.xml | 2 +- .../adminhtml/ui_component/category_form.xml | 2 +- .../adminhtml/ui_component/cms_page_form.xml | 2 +- .../ui_component/sales_rule_form.xml | 6 ++--- .../Ui/Component/ConfigurationTest.php | 3 --- .../View/Layout/Reader/UiComponent.php | 22 +++++++++++-------- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml index c49bf084adf16..79b71c2bb26bf 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml @@ -424,7 +424,7 @@ - Magento\Catalog\Block\Adminhtml\Category\AssignProducts + diff --git a/app/code/Magento/GoogleOptimizer/view/adminhtml/ui_component/category_form.xml b/app/code/Magento/GoogleOptimizer/view/adminhtml/ui_component/category_form.xml index 7719d54873a91..11adc860d8931 100644 --- a/app/code/Magento/GoogleOptimizer/view/adminhtml/ui_component/category_form.xml +++ b/app/code/Magento/GoogleOptimizer/view/adminhtml/ui_component/category_form.xml @@ -13,7 +13,7 @@ - Magento\GoogleOptimizer\Block\Adminhtml\Catalog\Category\Edit\Googleoptimizer + diff --git a/app/code/Magento/GoogleOptimizer/view/adminhtml/ui_component/cms_page_form.xml b/app/code/Magento/GoogleOptimizer/view/adminhtml/ui_component/cms_page_form.xml index da6fee3404e43..d09be65f29134 100644 --- a/app/code/Magento/GoogleOptimizer/view/adminhtml/ui_component/cms_page_form.xml +++ b/app/code/Magento/GoogleOptimizer/view/adminhtml/ui_component/cms_page_form.xml @@ -13,7 +13,7 @@ - Magento\GoogleOptimizer\Block\Adminhtml\Form\CmsPage + diff --git a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml index 78b4ab3b982b5..054db1cd4f06a 100644 --- a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml +++ b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml @@ -409,7 +409,7 @@ - Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Conditions + @@ -521,7 +521,7 @@ - Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Actions + @@ -544,7 +544,7 @@ - Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Labels + diff --git a/dev/tests/integration/testsuite/Magento/Ui/Component/ConfigurationTest.php b/dev/tests/integration/testsuite/Magento/Ui/Component/ConfigurationTest.php index 087fc03b0e3c1..0972c705cdb35 100644 --- a/dev/tests/integration/testsuite/Magento/Ui/Component/ConfigurationTest.php +++ b/dev/tests/integration/testsuite/Magento/Ui/Component/ConfigurationTest.php @@ -53,9 +53,6 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase 'argument[@name="data"]/item[@name="config"]/item[@name="multiple"]' => [ '//*[@formElement="select"]', '//*[substring(@component, string-length(@component) - string-length("ui-group") +1) = "ui-group"]' - ], - 'argument[@name="block"]' => [ - '//*[@name="html_content"]' ] ]; diff --git a/lib/internal/Magento/Framework/View/Layout/Reader/UiComponent.php b/lib/internal/Magento/Framework/View/Layout/Reader/UiComponent.php index 69b5691510308..fe9ff2a396451 100644 --- a/lib/internal/Magento/Framework/View/Layout/Reader/UiComponent.php +++ b/lib/internal/Magento/Framework/View/Layout/Reader/UiComponent.php @@ -94,7 +94,10 @@ public function interpret(Context $readerContext, Element $currentElement) $scheduledStructure->setElementToIfconfigList($referenceName, $configPath, $this->scopeType); } - foreach ($this->getLayoutElementsFromUiConfiguration($referenceName) as $layoutElement) { + $elements = []; + $config = $this->uiConfigFactory->create(['componentName' => $referenceName])->get($referenceName); + $this->getLayoutElementsFromUiConfiguration([$referenceName => $config], $elements); + foreach ($elements as $layoutElement) { $layoutElement = simplexml_load_string( $layoutElement, Element::class @@ -108,19 +111,20 @@ public function interpret(Context $readerContext, Element $currentElement) /** * Find layout elements in UI configuration for correct layout generation * - * @param string $uiConfigName - * @return array + * @param array $config + * @param array $elements + * @return void */ - private function getLayoutElementsFromUiConfiguration($uiConfigName) + private function getLayoutElementsFromUiConfiguration(array $config, array &$elements = []) { - $elements = []; - $config = $this->uiConfigFactory->create(['componentName' => $uiConfigName])->get($uiConfigName); - foreach ($config['children'] as $name => $data) { + foreach ($config as $name => $data) { if (isset($data['arguments']['block']['layout'])) { - $elements[$name] = $data['arguments']['block']['layout']; + $elements[] = $data['arguments']['block']['layout']; + } + if (isset($data['children']) && !empty($data['children'])) { + $this->getLayoutElementsFromUiConfiguration($data['children'], $elements); } } - return $elements; } /** From d80ecbaf34f242ffe97eb13340763ec06c452038 Mon Sep 17 00:00:00 2001 From: "Karpenko, Oleksandr" Date: Tue, 11 Apr 2017 11:14:31 +0300 Subject: [PATCH 2/5] MAGETWO-52958: Better Semantic for UI Components --- .../Magento/Framework/View/Layout/Reader/UiComponent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/View/Layout/Reader/UiComponent.php b/lib/internal/Magento/Framework/View/Layout/Reader/UiComponent.php index fe9ff2a396451..8e2976809b225 100644 --- a/lib/internal/Magento/Framework/View/Layout/Reader/UiComponent.php +++ b/lib/internal/Magento/Framework/View/Layout/Reader/UiComponent.php @@ -117,7 +117,7 @@ public function interpret(Context $readerContext, Element $currentElement) */ private function getLayoutElementsFromUiConfiguration(array $config, array &$elements = []) { - foreach ($config as $name => $data) { + foreach ($config as $data) { if (isset($data['arguments']['block']['layout'])) { $elements[] = $data['arguments']['block']['layout']; } From 58047f8c2b90fe798f48c6d5d5fa037f02950c75 Mon Sep 17 00:00:00 2001 From: "Karpenko, Oleksandr" Date: Tue, 11 Apr 2017 13:10:04 +0300 Subject: [PATCH 3/5] MAGETWO-52958: Better Semantic for UI Components --- .../view/adminhtml/ui_component/sales_rule_form.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml index 054db1cd4f06a..02cab73f63896 100644 --- a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml +++ b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml @@ -409,7 +409,7 @@ - + @@ -521,7 +521,7 @@ - + @@ -544,7 +544,7 @@ - + From 329bdb2a8312f92b5d053714924dc3c2c079e074 Mon Sep 17 00:00:00 2001 From: "Karpenko, Oleksandr" Date: Wed, 12 Apr 2017 13:34:01 +0300 Subject: [PATCH 4/5] MAGETWO-52958: Better Semantic for UI Components --- app/code/Magento/Ui/Config/Data.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Ui/Config/Data.php b/app/code/Magento/Ui/Config/Data.php index a47b5cbc41e55..9c33eaf3fcf95 100644 --- a/app/code/Magento/Ui/Config/Data.php +++ b/app/code/Magento/Ui/Config/Data.php @@ -84,7 +84,6 @@ public function __construct( $this->componentName = $componentName; $this->argumentInterpreter = $argumentInterpreter; $this->cacheId = static::CACHE_ID . '_' . $componentName; - $this->initData(); } /** @@ -121,7 +120,7 @@ private function initData() */ public function merge(array $config) { - $this->data = array_replace_recursive($this->data, $config); + $this->data = array_replace_recursive($this->get(), $config); } /** @@ -133,6 +132,9 @@ public function merge(array $config) */ public function get($path = null, $default = null) { + if (empty($this->data)) { + $this->initData(); + } if ($path === null) { return $this->data; } From c0bfb0984a1d146078321d4d116f6ae0b23b433c Mon Sep 17 00:00:00 2001 From: "Karpenko, Oleksandr" Date: Thu, 20 Apr 2017 17:33:19 +0300 Subject: [PATCH 5/5] MAGETWO-52958: Better Semantic for UI Components --- lib/internal/Magento/Framework/Component/ComponentRegistrar.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php index 6e09052f8c8e7..94fbab98423d9 100644 --- a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php +++ b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php @@ -46,8 +46,6 @@ class ComponentRegistrar implements ComponentRegistrarInterface */ public static function register($type, $componentName, $path) { - $path = str_replace("magento2ee", "magento2ce", $path); - $path = str_replace("magento2b2b", "magento2ce", $path); self::validateType($type); if (isset(self::$paths[$type][$componentName])) { throw new \LogicException(