SourceItemRepositoryInterface.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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\InventoryApi\Api;
  8. /**
  9. * In Magento 2 Repository considered as an implementation of Facade pattern which provides a simplified interface
  10. * to a larger body of code responsible for Domain Entity management
  11. *
  12. * The main intention is to make API more readable and reduce dependencies of business logic code on the inner workings
  13. * of a module, since most code uses the facade, thus allowing more flexibility in developing the system
  14. *
  15. * Along with this such approach helps to segregate two responsibilities:
  16. * 1. Repository now could be considered as an API - Interface for usage (calling) in the business logic
  17. * 2. Separate class-commands to which Repository proxies initial call (like, Get Save GetList Delete) could be
  18. * considered as SPI - Interfaces that you should extend and implement to customize current behaviour
  19. *
  20. * The method save is absent, due to different semantic (save multiple)
  21. * @see SourceItemsSaveInterface
  22. *
  23. * There is no get method because SourceItem identifies by compound identifier (sku and source_code),
  24. * so need to use getList() method
  25. *
  26. * Used fully qualified namespaces in annotations for proper work of WebApi request parser
  27. *
  28. * @api
  29. */
  30. interface SourceItemRepositoryInterface
  31. {
  32. /**
  33. * Find SourceItems by SearchCriteria
  34. *
  35. * We need to have this method for direct work with SourceItems because this object contains
  36. * additional data like as qty, status (for example can be searchable by additional field)
  37. *
  38. * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
  39. * @return \Magento\InventoryApi\Api\Data\SourceItemSearchResultsInterface
  40. */
  41. public function getList(
  42. \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
  43. ): \Magento\InventoryApi\Api\Data\SourceItemSearchResultsInterface;
  44. }