Skip to content

Commit

Permalink
remove collection processor
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-kl1 committed Jul 19, 2018
1 parent 8a18c9b commit 329fa36
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions Model/EraseCustomerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ class EraseCustomerRepository implements EraseCustomerRepositoryInterface
*/
private $collectionFactory;

/**
* @var \Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface
*/
private $collectionProcessor;

/**
* @var \Opengento\Gdpr\Api\Data\EraseCustomerSearchResultsInterfaceFactory
*/
Expand All @@ -72,20 +67,17 @@ class EraseCustomerRepository implements EraseCustomerRepositoryInterface
* @param \Opengento\Gdpr\Model\ResourceModel\EraseCustomer $eraseCustomerResource
* @param \Opengento\Gdpr\Api\Data\EraseCustomerInterfaceFactory $eraseCustomerFactory
* @param \Opengento\Gdpr\Model\ResourceModel\EraseCustomer\CollectionFactory $collectionFactory
* @param \Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface $collectionProcessor
* @param \Opengento\Gdpr\Api\Data\EraseCustomerSearchResultsInterfaceFactory $searchResultsFactory
*/
public function __construct(
EraseCustomerResource $eraseCustomerResource,
EraseCustomerInterfaceFactory $eraseCustomerFactory,
CollectionFactory $collectionFactory,
CollectionProcessorInterface $collectionProcessor,
EraseCustomerSearchResultsInterfaceFactory $searchResultsFactory
) {
$this->eraseCustomerResource = $eraseCustomerResource;
$this->eraseCustomerFactory = $eraseCustomerFactory;
$this->collectionFactory = $collectionFactory;
$this->collectionProcessor = $collectionProcessor;
$this->searchResultsFactory = $searchResultsFactory;
}

Expand Down Expand Up @@ -155,11 +147,31 @@ public function getList(SearchCriteriaInterface $searchCriteria): SearchResultsI
/** @var \Opengento\Gdpr\Model\ResourceModel\EraseCustomer\Collection $collection */
$collection = $this->collectionFactory->create();

$this->collectionProcessor->process($searchCriteria, $collection);

/** @var \Opengento\Gdpr\Api\Data\EraseCustomerSearchResultsInterface $searchResults */
$searchResults = $this->searchResultsFactory->create();
$searchResults->setSearchCriteria($searchCriteria);

foreach ($searchCriteria->getFilterGroups() as $filterGroup) {
$fields = [];
$conditions = [];

foreach ($filterGroup->getFilters() as $filter) {
$fields[] = $filter->getField();
$conditions[] = [$filter->getConditionType() => $filter->getValue()];
}

$collection->addFieldToFilter($fields, $conditions);
}

if ($searchCriteria->getSortOrders()) {
foreach ($searchCriteria->getSortOrders() as $sortOrder) {
$collection->addOrder($sortOrder->getField(), $sortOrder->getDirection());
}
}

$collection->setCurPage($searchCriteria->getCurrentPage());
$collection->setPageSize($searchCriteria->getPageSize());

$searchResults->setItems($collection->getItems());
$searchResults->setTotalCount($collection->count());

Expand Down

0 comments on commit 329fa36

Please sign in to comment.