TestRepository.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\TestModuleJoinDirectives\Model;
  7. use Magento\TestModuleJoinDirectives\Api\TestRepositoryInterface;
  8. use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
  9. /**
  10. * Model TestRepository
  11. */
  12. class TestRepository implements TestRepositoryInterface
  13. {
  14. /**
  15. * @var \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory
  16. */
  17. private $quoteCollectionFactory;
  18. /**
  19. * @var \Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory
  20. */
  21. private $searchResultsDataFactory;
  22. /**
  23. * @var JoinProcessorInterface
  24. */
  25. private $extensionAttributesJoinProcessor;
  26. /**
  27. * @param \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory $quoteCollectionFactory
  28. * @param \Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory $searchResultsDataFactory
  29. * @param JoinProcessorInterface $extensionAttributesJoinProcessor
  30. */
  31. public function __construct(
  32. \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory $quoteCollectionFactory,
  33. \Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory $searchResultsDataFactory,
  34. JoinProcessorInterface $extensionAttributesJoinProcessor
  35. ) {
  36. $this->quoteCollectionFactory = $quoteCollectionFactory;
  37. $this->searchResultsDataFactory = $searchResultsDataFactory;
  38. $this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
  44. {
  45. $quoteCollection = $this->quoteCollectionFactory->create();
  46. $this->extensionAttributesJoinProcessor->process($quoteCollection);
  47. $searchData = $this->searchResultsDataFactory->create();
  48. $searchData->setSearchCriteria($searchCriteria);
  49. $searchData->setItems($quoteCollection->getItems());
  50. return $searchData;
  51. }
  52. }