Skip to content

Commit 7592b8c

Browse files
author
Oleksii Korshenko
authored
MAGETWO-69805: Return array of blocks as items instead of array of arrays #9157
2 parents d1b86ae + e091cfd commit 7592b8c

File tree

2 files changed

+2
-31
lines changed

2 files changed

+2
-31
lines changed

app/code/Magento/Cms/Model/BlockRepository.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -154,25 +154,10 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $criteria
154154

155155
$this->collectionProcessor->process($criteria, $collection);
156156

157-
$blocks = [];
158-
/** @var Block $blockModel */
159-
foreach ($collection as $blockModel) {
160-
$blockData = $this->dataBlockFactory->create();
161-
$this->dataObjectHelper->populateWithArray(
162-
$blockData,
163-
$blockModel->getData(),
164-
\Magento\Cms\Api\Data\BlockInterface::class
165-
);
166-
$blocks[] = $this->dataObjectProcessor->buildOutputDataArray(
167-
$blockData,
168-
\Magento\Cms\Api\Data\BlockInterface::class
169-
);
170-
}
171-
172157
/** @var Data\BlockSearchResultsInterface $searchResults */
173158
$searchResults = $this->searchResultsFactory->create();
174159
$searchResults->setSearchCriteria($criteria);
175-
$searchResults->setItems($blocks);
160+
$searchResults->setItems($collection->getItems());
176161
$searchResults->setTotalCount($collection->getSize());
177162
return $searchResults;
178163
}

app/code/Magento/Cms/Test/Unit/Model/BlockRepositoryTest.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -263,22 +263,8 @@ public function testGetList()
263263
->willReturnSelf();
264264
$this->blockSearchResult->expects($this->once())
265265
->method('setItems')
266-
->with(['someData'])
266+
->with([$this->block])
267267
->willReturnSelf();
268-
269-
$this->block->expects($this->once())
270-
->method('getData')
271-
->willReturn(['data']);
272-
273-
$this->dataHelper->expects($this->once())
274-
->method('populateWithArray')
275-
->with($this->blockData, ['data'], \Magento\Cms\Api\Data\BlockInterface::class);
276-
277-
$this->dataObjectProcessor->expects($this->once())
278-
->method('buildOutputDataArray')
279-
->with($this->blockData, \Magento\Cms\Api\Data\BlockInterface::class)
280-
->willReturn('someData');
281-
282268
$this->assertEquals($this->blockSearchResult, $this->repository->getList($criteria));
283269
}
284270
}

0 commit comments

Comments
 (0)