SourceRepository.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Inventory\Model;
  8. use Magento\Framework\Api\SearchCriteriaInterface;
  9. use Magento\Inventory\Model\Source\Command\GetInterface;
  10. use Magento\Inventory\Model\Source\Command\GetListInterface;
  11. use Magento\Inventory\Model\Source\Command\SaveInterface;
  12. use Magento\InventoryApi\Api\Data\SourceInterface;
  13. use Magento\InventoryApi\Api\Data\SourceSearchResultsInterface;
  14. use Magento\InventoryApi\Api\SourceRepositoryInterface;
  15. /**
  16. * @inheritdoc
  17. */
  18. class SourceRepository implements SourceRepositoryInterface
  19. {
  20. /**
  21. * @var SaveInterface
  22. */
  23. private $commandSave;
  24. /**
  25. * @var GetInterface
  26. */
  27. private $commandGet;
  28. /**
  29. * @var GetListInterface
  30. */
  31. private $commandGetList;
  32. /**
  33. * @param SaveInterface $commandSave
  34. * @param GetInterface $commandGet
  35. * @param GetListInterface $commandGetList
  36. */
  37. public function __construct(
  38. SaveInterface $commandSave,
  39. GetInterface $commandGet,
  40. GetListInterface $commandGetList
  41. ) {
  42. $this->commandSave = $commandSave;
  43. $this->commandGet = $commandGet;
  44. $this->commandGetList = $commandGetList;
  45. }
  46. /**
  47. * @inheritdoc
  48. */
  49. public function save(SourceInterface $source): void
  50. {
  51. $this->commandSave->execute($source);
  52. }
  53. /**
  54. * @inheritdoc
  55. */
  56. public function get(string $sourceCode): SourceInterface
  57. {
  58. return $this->commandGet->execute($sourceCode);
  59. }
  60. /**
  61. * @inheritdoc
  62. */
  63. public function getList(SearchCriteriaInterface $searchCriteria = null): SourceSearchResultsInterface
  64. {
  65. return $this->commandGetList->execute($searchCriteria);
  66. }
  67. }