Skip to content

Commit ce27edc

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 58f0ba1 commit ce27edc

File tree

4 files changed

+24
-34
lines changed

4 files changed

+24
-34
lines changed

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -301,29 +301,4 @@ 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-
}
329304
}

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,19 @@ private function getDataProvider()
217217
*/
218218
private function getFilterIds()
219219
{
220+
$idsArray = [];
220221
$this->applySelectionOnTargetProvider();
221-
return $this->getComponent()->getAllIds();
222+
if ($this->getDataProvider() instanceof \Magento\Ui\DataProvider\AbstractDataProvider) {
223+
// Use collection's getItems for optimization purposes
224+
return $this->getDataProvider()->getAllIds();
225+
} else {
226+
$searchResult = $this->getDataProvider()->getSearchResult();
227+
// Use compatible search api getItems when searchResult is not a collection.
228+
foreach ($searchResult->getItems() as $item) {
229+
/** @var $item \Magento\Framework\Api\Search\DocumentInterface */
230+
$idsArray[] = $item->getId();
231+
}
232+
}
233+
return $idsArray;
222234
}
223235
}

app/code/Magento/Ui/DataProvider/AbstractDataProvider.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function getSearchCriteria()
172172
/**
173173
* Returns SearchResult
174174
*
175-
* @return null
175+
* @return AbstractCollection
176176
*/
177177
public function getSearchResult()
178178
{
@@ -279,4 +279,14 @@ public function setConfigData($config)
279279
{
280280
$this->data['config'] = $config;
281281
}
282+
283+
/**
284+
* Retrieve all ids from Search Result
285+
*
286+
* @return int[]
287+
*/
288+
public function getAllIds()
289+
{
290+
return $this->getSearchResult()->getAllIds();
291+
}
282292
}

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,4 @@ 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();
135128
}

0 commit comments

Comments
 (0)