Skip to content

Commit 60d05a5

Browse files
committed
Merge branch 'MAGETWO-52958-1' of github.com:magento-frontend/magento2ce into MAGETWO-52958-1
2 parents 8b0f563 + 34bc9de commit 60d05a5

33 files changed

+283
-94
lines changed

app/code/Magento/Ui/Api/BookmarkManagementInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
namespace Magento\Ui\Api;
77

88
/**
9-
* Interface for managing bookmarks.
9+
* Interface for managing bookmarks
10+
*
1011
* @api
1112
*/
1213
interface BookmarkManagementInterface

app/code/Magento/Ui/Api/BookmarkRepositoryInterface.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
namespace Magento\Ui\Api;
77

88
/**
9-
* Bookmark CRUD interface.
9+
* Bookmark CRUD interface
10+
*
1011
* @api
1112
*/
1213
interface BookmarkRepositoryInterface
1314
{
1415
/**
15-
* Save bookmark.
16+
* Save bookmark
1617
*
1718
* @param \Magento\Ui\Api\Data\BookmarkInterface $bookmark
1819
* @return \Magento\Ui\Api\Data\BookmarkInterface
@@ -21,7 +22,7 @@ interface BookmarkRepositoryInterface
2122
public function save(\Magento\Ui\Api\Data\BookmarkInterface $bookmark);
2223

2324
/**
24-
* Retrieve bookmark.
25+
* Retrieve bookmark
2526
*
2627
* @param int $bookmarkId
2728
* @return \Magento\Ui\Api\Data\BookmarkInterface
@@ -30,7 +31,7 @@ public function save(\Magento\Ui\Api\Data\BookmarkInterface $bookmark);
3031
public function getById($bookmarkId);
3132

3233
/**
33-
* Retrieve bookmarks matching the specified criteria.
34+
* Retrieve bookmarks matching the specified criteria
3435
*
3536
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
3637
* @return \Magento\Ui\Api\Data\BookmarkSearchResultsInterface
@@ -39,7 +40,7 @@ public function getById($bookmarkId);
3940
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
4041

4142
/**
42-
* Delete bookmark.
43+
* Delete bookmark
4344
*
4445
* @param \Magento\Ui\Api\Data\BookmarkInterface $bookmark
4546
* @return bool true on success
@@ -48,7 +49,7 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
4849
public function delete(\Magento\Ui\Api\Data\BookmarkInterface $bookmark);
4950

5051
/**
51-
* Delete bookmark by ID.
52+
* Delete bookmark by ID
5253
*
5354
* @param int $bookmarkId
5455
* @return bool true on success

app/code/Magento/Ui/Api/Data/BookmarkExtensionInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
namespace Magento\Ui\Api\Data;
77

88
/**
9-
* Bookmark extension interface.
9+
* Bookmark extension interface
10+
*
1011
* @api
1112
*/
1213
interface BookmarkExtensionInterface extends \Magento\Framework\Api\ExtensionAttributesInterface

app/code/Magento/Ui/Api/Data/BookmarkInterface.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
namespace Magento\Ui\Api\Data;
77

88
/**
9-
* Bookmark interface.
9+
* Bookmark interface
10+
*
1011
* @api
1112
*/
1213
interface BookmarkInterface extends BookmarkExtensionInterface
@@ -161,14 +162,14 @@ public function setUpdatedAt($updatedAt);
161162
public function setCurrent($isCurrent);
162163

163164
/**
164-
* Retrieve existing extension attributes object or create a new one.
165+
* Retrieve existing extension attributes object or create a new one
165166
*
166167
* @return \Magento\Ui\Api\Data\BookmarkExtensionInterface|null
167168
*/
168169
public function getExtensionAttributes();
169170

170171
/**
171-
* Set an extension attributes object.
172+
* Set an extension attributes object
172173
*
173174
* @param \Magento\Ui\Api\Data\BookmarkExtensionInterface $extensionAttributes
174175
* @return $this

app/code/Magento/Ui/Api/Data/BookmarkSearchResultsInterface.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@
77
namespace Magento\Ui\Api\Data;
88

99
/**
10-
* Interface for bookmark search results.
10+
* Interface for bookmark search results
11+
*
1112
* @api
1213
*/
1314
interface BookmarkSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface
1415
{
1516
/**
16-
* Get customers list.
17+
* Get customers list
1718
*
1819
* @return \Magento\Ui\Api\Data\BookmarkInterface[]
1920
*/
2021
public function getItems();
2122

2223
/**
23-
* Set customers list.
24+
* Set customers list
2425
*
2526
* @api
2627
* @param \Magento\Ui\Api\Data\BookmarkInterface[] $items

app/code/Magento/Ui/Block/Component/StepsWizard.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
*/
66
namespace Magento\Ui\Block\Component;
77

8+
/**
9+
* Multi steps wizard block
10+
*
11+
* @api
12+
*/
813
class StepsWizard extends \Magento\Framework\View\Element\Template
914
{
1015
/**
@@ -67,10 +72,12 @@ public function getInitData()
6772

6873
/**
6974
* @param array $initData
70-
* @return array
75+
* @return $this
7176
*/
7277
public function setInitData($initData)
7378
{
7479
$this->initData = $initData;
80+
81+
return $this;
7582
}
7683
}

app/code/Magento/Ui/Block/Component/StepsWizard/StepAbstract.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,29 @@
55
*/
66
namespace Magento\Ui\Block\Component\StepsWizard;
77

8+
/**
9+
* Abstract block for multi-step wizard UI
10+
*/
811
abstract class StepAbstract extends \Magento\Framework\View\Element\Template implements StepInterface
912
{
1013
/**
11-
* {@inheritdoc}
14+
* @inheritdoc
1215
*/
1316
public function getContent()
1417
{
1518
return $this->toHtml();
1619
}
1720

1821
/**
19-
* {@inheritdoc}
22+
* @inheritdoc
2023
*/
2124
public function getParentComponentName()
2225
{
2326
return $this->getParentBlock()->getComponentName();
2427
}
2528

2629
/**
27-
* {@inheritdoc}
30+
* @inheritdoc
2831
*/
2932
public function getComponentName()
3033
{

app/code/Magento/Ui/Block/Component/StepsWizard/StepInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
*/
66
namespace Magento\Ui\Block\Component\StepsWizard;
77

8+
/**
9+
* Interface for multi-step wizard blocks
10+
*
11+
* @api
12+
*/
813
interface StepInterface extends \Magento\Framework\View\Element\BlockInterface
914
{
1015
/**

app/code/Magento/Ui/Block/Logger.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
use Magento\Framework\View\Element\Template;
99
use Magento\Ui\Model\Config;
1010

11+
/**
12+
* Logger block
13+
*
14+
* @api
15+
*/
1116
class Logger extends Template
1217
{
1318
/**

app/code/Magento/Ui/Config/Converter.php

Lines changed: 94 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
use Magento\Framework\View\Layout\Argument\Parser;
1111
use Magento\Ui\Config\Argument\ParserInterface;
1212

13+
/**
14+
* Converter for UI Component instances configuration files
15+
*/
1316
class Converter implements ConfigConverterInterface
1417
{
1518
/**
@@ -125,43 +128,15 @@ private function toArray(\DOMNode $node)
125128
$result[$attributes[static::NAME_ATTRIBUTE_KEY]] = $this->argumentParser->parse($node);
126129
} else {
127130
$resultComponent = $this->convertNode($node);
128-
$arguments = [];
129-
$childResult = [];
130-
for ($i = 0, $iLength = $node->childNodes->length; $i < $iLength; ++$i) {
131-
$itemNode = $node->childNodes->item($i);
132-
if ($itemNode->localName == null) {
133-
continue;
134-
}
135-
if ($itemNode->localName === static::ARGUMENT_KEY) {
136-
$arguments += $this->toArray($itemNode);
137-
} elseif (
138-
$this->converterUtils->isUiComponent($itemNode)
139-
&& isset($this->schemaMap[$itemNode->localName])
140-
) {
141-
$itemNodeName = $this->converterUtils->getComponentName($itemNode);
142-
$childResult[$itemNodeName] = $this->toArray($itemNode);
143-
// 'uiComponentType' is needed this for Reader to merge default values from definition
144-
$childResult[$itemNodeName]['uiComponentType'] = $itemNode->localName;
145-
} else {
146-
continue;
147-
}
148-
}
149-
150-
if (!empty($arguments) || !empty($resultComponent)) {
151-
$arguments = array_replace_recursive($resultComponent, $arguments);
152-
$result[static::DATA_ARGUMENTS_KEY] = $arguments;
153-
}
154-
155-
if (!empty($attributes)) {
156-
$result[static::DATA_ATTRIBUTES_KEY] = $attributes;
157-
}
131+
list($arguments, $childResult) = $this->convertChildNodes($node);
158132

159-
if ($node->parentNode !== null) {
160-
$result[static::DATA_COMPONENTS_KEY] = $childResult;
161-
} else {
162-
$result = $childResult;
163-
}
133+
$result = array_merge(
134+
$this->processArguments($arguments, $resultComponent),
135+
$this->processAttributes($attributes),
136+
$this->processChildResult($node, $childResult)
137+
);
164138
}
139+
165140
break;
166141
}
167142

@@ -180,7 +155,9 @@ public function convert($source)
180155
return [];
181156
}
182157

183-
$this->schemaMap = $this->reader->read();
158+
if (!$this->schemaMap) {
159+
$this->schemaMap = $this->reader->read();
160+
}
184161
$result = $this->toArray($source);
185162
return empty($result) ? $result : reset($result);
186163
}
@@ -214,4 +191,85 @@ private function convertNode(\DOMNode $node)
214191

215192
return $resultComponent;
216193
}
194+
195+
/**
196+
* Process component arguments
197+
*
198+
* @param array $arguments
199+
* @param array $resultComponent
200+
* @return array
201+
*/
202+
private function processArguments(array $arguments, array $resultComponent)
203+
{
204+
$result = [];
205+
if (!empty($arguments) || !empty($resultComponent)) {
206+
$result[static::DATA_ARGUMENTS_KEY] = array_replace_recursive($resultComponent, $arguments);
207+
}
208+
return $result;
209+
}
210+
211+
/**
212+
* Process component attributes
213+
*
214+
* @param array $attributes
215+
* @return array
216+
*/
217+
private function processAttributes(array $attributes)
218+
{
219+
$result = [];
220+
if (!empty($attributes)) {
221+
$result[static::DATA_ATTRIBUTES_KEY] = $attributes;
222+
}
223+
return $result;
224+
}
225+
226+
/**
227+
* @param \DOMNode $node
228+
* @param array $childResult
229+
* @return array
230+
*/
231+
private function processChildResult(\DOMNode $node, array $childResult)
232+
{
233+
$result = [];
234+
if ($node->parentNode !== null) {
235+
$result[static::DATA_COMPONENTS_KEY] = $childResult;
236+
} else {
237+
$result = $childResult;
238+
}
239+
240+
return $result;
241+
}
242+
243+
/**
244+
* Convert child nodes of $node
245+
*
246+
* @param \DOMNode $node
247+
* @return array
248+
*/
249+
private function convertChildNodes(\DOMNode $node)
250+
{
251+
$arguments = [];
252+
$childResult = [];
253+
for ($i = 0, $iLength = $node->childNodes->length; $i < $iLength; ++$i) {
254+
$itemNode = $node->childNodes->item($i);
255+
if ($itemNode->localName == null) {
256+
continue;
257+
}
258+
if ($itemNode->localName === static::ARGUMENT_KEY) {
259+
$arguments += $this->toArray($itemNode);
260+
} elseif (
261+
$this->converterUtils->isUiComponent($itemNode)
262+
&& isset($this->schemaMap[$itemNode->localName])
263+
) {
264+
$itemNodeName = $this->converterUtils->getComponentName($itemNode);
265+
$childResult[$itemNodeName] = $this->toArray($itemNode);
266+
// 'uiComponentType' is needed this for Reader to merge default values from definition
267+
$childResult[$itemNodeName]['uiComponentType'] = $itemNode->localName;
268+
} else {
269+
continue;
270+
}
271+
}
272+
273+
return [$arguments, $childResult];
274+
}
217275
}

0 commit comments

Comments
 (0)