Collection.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Model\ResourceModel\Location\Grid;
  6. use Magento\Framework\Api\FilterBuilder;
  7. use Magento\Framework\Api\SearchCriteriaBuilder;
  8. use Magento\Framework\Api\SearchCriteriaInterface;
  9. use Magento\Framework\Data\Collection\EntityFactoryInterface;
  10. use Magento\Framework\Message\ManagerInterface;
  11. use Temando\Shipping\Model\LocationInterface;
  12. use Temando\Shipping\Model\ResourceModel\Repository\LocationRepositoryInterface;
  13. use Temando\Shipping\Model\ResourceModel\Webservice\Collection as ApiCollection;
  14. /**
  15. * Temando Location Resource Collection
  16. *
  17. * @package Temando\Shipping\Model
  18. * @author Christoph Aßmann <christoph.assmann@netresearch.de>
  19. * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
  20. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  21. * @link http://www.temando.com/
  22. */
  23. class Collection extends ApiCollection
  24. {
  25. /**
  26. * @var LocationRepositoryInterface
  27. */
  28. private $locationRepository;
  29. /**
  30. * Collection constructor.
  31. * @param EntityFactoryInterface $entityFactory
  32. * @param ManagerInterface $messageManager
  33. * @param FilterBuilder $filterBuilder
  34. * @param SearchCriteriaBuilder $searchCriteriaBuilder
  35. * @param LocationRepositoryInterface $locationRepository
  36. */
  37. public function __construct(
  38. EntityFactoryInterface $entityFactory,
  39. ManagerInterface $messageManager,
  40. FilterBuilder $filterBuilder,
  41. SearchCriteriaBuilder $searchCriteriaBuilder,
  42. LocationRepositoryInterface $locationRepository
  43. ) {
  44. $this->locationRepository = $locationRepository;
  45. parent::__construct($entityFactory, $messageManager, $filterBuilder, $searchCriteriaBuilder);
  46. }
  47. /**
  48. * @param SearchCriteriaInterface $criteria
  49. * @return LocationInterface[]
  50. */
  51. public function fetchData(SearchCriteriaInterface $criteria)
  52. {
  53. $locations = $this->locationRepository->getList(
  54. $criteria->getCurrentPage(),
  55. $criteria->getPageSize()
  56. );
  57. return $locations;
  58. }
  59. }