Skip to content

Commit

Permalink
Merge pull request #1051 from magento-frontend/MAGETWO-52958-2
Browse files Browse the repository at this point in the history
Story
- MAGETWO-52958 Better Semantic for UI Components
  • Loading branch information
VladimirZaets authored Apr 24, 2017
2 parents 32e09b5 + 237547a commit e0bd129
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@
</settings>
<container name="assign_products_container" sortOrder="160">
<htmlContent name="html_content">
<argument name="block" xsi:type="object">Magento\Catalog\Block\Adminhtml\Category\AssignProducts</argument>
<block name="gallery" class="Magento\Catalog\Block\Adminhtml\Category\AssignProducts"/>
</htmlContent>
</container>
</fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</settings>
<container name="google_experiment_container" sortOrder="250">
<htmlContent name="html_content">
<argument name="block" xsi:type="object">Magento\GoogleOptimizer\Block\Adminhtml\Catalog\Category\Edit\Googleoptimizer</argument>
<block name="googleoptimizer" class="Magento\GoogleOptimizer\Block\Adminhtml\Catalog\Category\Edit\Googleoptimizer"/>
</htmlContent>
</container>
</fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</settings>
<container name="google_experiment_container" sortOrder="250">
<htmlContent name="html_content">
<argument name="block" xsi:type="object">Magento\GoogleOptimizer\Block\Adminhtml\Form\CmsPage</argument>
<block name="googleOptimizerBlockAdminhtmlFormCmsPage" class="MagentoGoogleOptimizerBlockAdminhtmlFormCmsPage"/>
</htmlContent>
</container>
</fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
</settings>
<container name="conditions_apply_to" sortOrder="10">
<htmlContent name="html_content">
<argument name="block" xsi:type="object">Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Conditions</argument>
<block name="conditions_apply_to" class="Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Conditions" />
</htmlContent>
</container>
</fieldset>
Expand Down Expand Up @@ -521,7 +521,7 @@
</field>
<container name="actions_apply_to" sortOrder="40">
<htmlContent name="html_content">
<argument name="block" xsi:type="object">Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Actions</argument>
<block name="actions_apply_to" class="Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Actions"/>
</htmlContent>
</container>
</fieldset>
Expand All @@ -544,7 +544,7 @@
</field>
<container name="store_view_labels" sortOrder="40">
<htmlContent name="html_content">
<argument name="block" xsi:type="object">Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Labels</argument>
<block name="store_view_labels" class="Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Labels"/>
</htmlContent>
</container>
</fieldset>
Expand Down
6 changes: 4 additions & 2 deletions app/code/Magento/Ui/Config/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public function __construct(
$this->componentName = $componentName;
$this->argumentInterpreter = $argumentInterpreter;
$this->cacheId = static::CACHE_ID . '_' . $componentName;
$this->initData();
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]'
]
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
22 changes: 13 additions & 9 deletions lib/internal/Magento/Framework/View/Layout/Reader/UiComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ public function interpret(Context $readerContext, Element $currentElement)
);
$scheduledStructure->setStructureElementData($referenceName, ['attributes' => $attributes]);

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
Expand All @@ -110,19 +113,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 $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;
}

/**
Expand Down

0 comments on commit e0bd129

Please sign in to comment.