Skip to content

Commit 809421e

Browse files
committed
MAGETWO-37934: Cannot create customer from admin
- Move retrieving $dataScope to uiComponent implementation
1 parent 7ad03d2 commit 809421e

File tree

5 files changed

+45
-18
lines changed

5 files changed

+45
-18
lines changed

app/code/Magento/Ui/Component/AbstractComponent.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,12 @@ public function prepareDataSource(array & $dataSource)
232232
{
233233
//
234234
}
235+
236+
/**
237+
* @return array
238+
*/
239+
public function getDataSourceData()
240+
{
241+
return [];
242+
}
235243
}

app/code/Magento/Ui/Component/Form.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,24 @@ public function getComponentName()
2323
{
2424
return static::NAME;
2525
}
26+
27+
/**
28+
* @inheritdoc
29+
*/
30+
public function getDataSourceData()
31+
{
32+
$dataSource = [];
33+
$id = $this->getContext()->getRequestParam($this->getContext()->getDataProvider()->getRequestFieldName());
34+
if ($id) { // case form
35+
$this->getContext()->getDataProvider()
36+
->addFilter($this->getContext()->getDataProvider()->getPrimaryFieldName(), $id);
37+
}
38+
$data = $this->getContext()->getDataProvider()->getData();
39+
if (isset($data[$id])) {
40+
$dataSource = [
41+
'data' => $data[$id]
42+
];
43+
}
44+
return $dataSource;
45+
}
2646
}

app/code/Magento/Ui/Component/Listing.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,15 @@ public function getComponentName()
3030
{
3131
return static::NAME;
3232
}
33+
34+
/**
35+
* @inheritdoc
36+
*/
37+
public function getDataSourceData()
38+
{
39+
return [
40+
'data' => $this->getContext()->getDataProvider()->getData(),
41+
'totalCount' => $this->getContext()->getDataProvider()->count()
42+
];
43+
}
3344
}

lib/internal/Magento/Framework/View/Element/UiComponent/Context.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -206,25 +206,8 @@ public function getDataProvider()
206206
*/
207207
public function getDataSourceData(UiComponentInterface $component)
208208
{
209-
$dataSource = [];
210-
$id = $this->getRequestParam($this->getDataProvider()->getRequestFieldName());
211-
if ($id) { // case form
212-
$this->getDataProvider()->addFilter($this->getDataProvider()->getPrimaryFieldName(), $id);
213-
$data = $this->getDataProvider()->getData();
214-
if (isset($data[$id])) {
215-
$dataSource = [
216-
'data' => $data[$id]
217-
];
218-
}
219-
} else { // case listing
220-
$dataSource = [
221-
'data' => $this->getDataProvider()->getData(),
222-
'totalCount' => $this->getDataProvider()->count()
223-
];
224-
}
225-
209+
$dataSource = $component->getDataSourceData();
226210
$this->prepareDataSource($dataSource, $component);
227-
228211
$dataProviderConfig = $this->getDataProvider()->getConfigData();
229212
return [
230213
$this->getDataProvider()->getName() => [

lib/internal/Magento/Framework/View/Element/UiComponentInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,9 @@ public function prepare();
116116
* @return void
117117
*/
118118
public function prepareDataSource(array & $dataSource);
119+
120+
/**
121+
* @return array
122+
*/
123+
public function getDataSourceData();
119124
}

0 commit comments

Comments
 (0)