resourceModel = $resourceModel; $this->customerLinkFactory = $customerLinkFactory; $this->filterBuilder = $filterBuilder; $this->searchCriteriaBuilder = $searchCriteriaBuilder; $this->searchResultsFactory = $searchResultsFactory; $this->collectionFactory = $collectionFactory; $this->collectionProcessor = $collectionProcessor; } /** * {@inheritdoc} */ public function get($customerId) { $customerLink = $this->customerLinkFactory->create(); $this->resourceModel->load($customerLink, $customerId, 'customer_id'); return $customerLink; } /** * {@inheritdoc} */ public function getById($entityId) { $customerLink = $this->customerLinkFactory->create(); $this->resourceModel->load($customerLink, $entityId); return $customerLink; } /** * {@inheritdoc} */ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) { $collection = $this->collectionFactory->create(); $this->collectionProcessor->process($searchCriteria, $collection); $searchResults = $this->searchResultsFactory->create(); $searchResults->setSearchCriteria($searchCriteria); $searchResults->setItems($collection->getItems()); return $searchResults; } /** * {@inheritdoc} */ public function delete(CustomerLinkInterface $customerLink) { try { $this->resourceModel->delete($customerLink); } catch (\Exception $exception) { throw new \Magento\Framework\Exception\CouldNotDeleteException(__($exception->getMessage())); } return true; } /** * {@inheritdoc} */ public function deleteById($entityId) { return $this->delete($this->getById($entityId)); } /** * {@inheritdoc} */ public function save(CustomerLinkInterface $customerLink) { try { $this->resourceModel->save($customerLink); } catch (\Exception $exception) { throw new \Magento\Framework\Exception\CouldNotSaveException( __('Could not save Amazon customer link: %1', $exception->getMessage()), $exception ); } return $customerLink; } }