Skip to content

Commit 58f0ba1

Browse files
committed
MAGETWO-66402: Backward Incompatible Change
- moving getAllIds into \Magento\Framework\View\Element\UiComponentInterface as it already contains methods not related to interface and we will probably deprecate this interface at some point and refactor UiComponent
1 parent 62667cb commit 58f0ba1

File tree

6 files changed

+33
-33
lines changed

6 files changed

+33
-33
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,29 @@ protected function initObservers(array & $data = [])
301301
}
302302
}
303303
}
304+
305+
306+
/**
307+
* Retrieve all ids from Search Result
308+
*
309+
* @return int[]
310+
*/
311+
public function getAllIds()
312+
{
313+
$searchResult = $this->getContext()->getDataProvider()->getSearchResult();
314+
$idsArray = [];
315+
316+
if ($searchResult instanceof \Magento\Eav\Model\Entity\Collection\AbstractCollection
317+
|| $searchResult instanceof \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
318+
) {
319+
// Query optimization as SearchResultInterface doesn't have optimization for retrieving just ids
320+
$idsArray = $searchResult->getAllIds();
321+
} else {
322+
foreach ($searchResult->getItems() as $item) {
323+
/** @var $item \Magento\Framework\Api\Search\DocumentInterface */
324+
$idsArray[] = $item->getId();
325+
}
326+
}
327+
return $idsArray;
328+
}
304329
}

app/code/Magento/Ui/Component/MassAction/Filter.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,6 @@ private function getDataProvider()
218218
private function getFilterIds()
219219
{
220220
$this->applySelectionOnTargetProvider();
221-
if ($this->getDataProvider()->getSearchResult()) {
222-
return $this->getDataProvider()->getSearchResult()->getAllIds();
223-
}
224-
return [];
221+
return $this->getComponent()->getAllIds();
225222
}
226223
}

lib/internal/Magento/Framework/Api/Search/SearchResult.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,4 @@ public function setTotalCount($totalCount)
8585
{
8686
return $this->setData(self::TOTAL_COUNT, $totalCount);
8787
}
88-
89-
/**
90-
* Retrieve ids of all items
91-
*
92-
* @return array
93-
*/
94-
public function getAllIds()
95-
{
96-
$ids = [];
97-
foreach ($this->getItems() as $item) {
98-
$ids[] = $item->getId();
99-
}
100-
return $ids;
101-
}
10288
}

lib/internal/Magento/Framework/Api/Search/SearchResultInterface.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,4 @@ public function setAggregations($aggregations);
5353
* @return \Magento\Framework\Api\Search\SearchCriteriaInterface
5454
*/
5555
public function getSearchCriteria();
56-
57-
/**
58-
* Retrieve all ids from list
59-
*
60-
* @return int[]
61-
*/
62-
public function getAllIds();
6356
}

lib/internal/Magento/Framework/Api/Test/Unit/Search/SearchResultTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ protected function setUp()
5454
);
5555
}
5656

57-
/**
58-
* Test getAllIds
59-
*/
60-
public function testGetAllIds()
61-
{
62-
$this->assertEquals([1, 2], $this->search->getAllIds());
63-
}
64-
6557
/**
6658
* Test getItems
6759
*/

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,11 @@ public function prepareDataSource(array $dataSource);
125125
* @return array
126126
*/
127127
public function getDataSourceData();
128+
129+
/**
130+
* Retrieve all ids from Search Result
131+
*
132+
* @return int[]
133+
*/
134+
public function getAllIds();
128135
}

0 commit comments

Comments
 (0)