Skip to content

Commit

Permalink
#42285 Update return type object
Browse files Browse the repository at this point in the history
  • Loading branch information
dawiddczaja committed Jul 23, 2018
1 parent 1fa3396 commit aef0ffc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Api/MenuRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function getById($id);
*
* @api
* @param \Magento\Framework\Api\SearchCriteriaInterface $criteria
* @return \Snowdog\Menu\Api\Data\MenuSearchResultsInterface|string
* @return \Snowdog\Menu\Api\Data\MenuSearchResultsInterface
*/
public function getList(SearchCriteriaInterface $criteria);

Expand Down
17 changes: 13 additions & 4 deletions Model/MenuRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,31 @@
use Snowdog\Menu\Api\MenuRepositoryInterface;
use Snowdog\Menu\Api\Data\MenuInterface;
use Snowdog\Menu\Model\ResourceModel\Menu\CollectionFactory;
use Snowdog\Menu\Api\Data\MenuSearchResultsInterfaceFactory;

use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\Framework\Api\SearchResultsInterfaceFactory;

class MenuRepository implements MenuRepositoryInterface
{
protected $objectFactory;
protected $collectionFactory;

/**
* @var MenuSearchResultsInterfaceFactory
*/
private $menuSearchResultsFactory;

public function __construct(
MenuFactory $objectFactory,
CollectionFactory $collectionFactory,
SearchResultsInterfaceFactory $searchResultsFactory
MenuSearchResultsInterfaceFactory $menuSearchResults
) {
$this->objectFactory = $objectFactory;
$this->collectionFactory = $collectionFactory;
$this->searchResultsFactory = $searchResultsFactory;
$this->menuSearchResultsFactory = $menuSearchResults;
}

public function save(MenuInterface $object)
Expand Down Expand Up @@ -61,9 +66,12 @@ public function deleteById($id)
return $this->delete($this->getById($id));
}

/**
* @inheritdoc
*/
public function getList(SearchCriteriaInterface $criteria)
{
$searchResults = $this->searchResultsFactory->create();
$searchResults = $this->menuSearchResultsFactory->create();
$searchResults->setSearchCriteria($criteria);
$collection = $this->collectionFactory->create();
foreach ($criteria->getFilterGroups() as $filterGroup) {
Expand Down Expand Up @@ -96,6 +104,7 @@ public function getList(SearchCriteriaInterface $criteria)
$objects[] = $objectModel;
}
$searchResults->setItems($objects);

return $searchResults;
}

Expand Down

0 comments on commit aef0ffc

Please sign in to comment.