AllSoapAndRest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\TestModule5\Service\V2;
  7. use Magento\TestModule5\Service\V2\Entity\AllSoapAndRest as AllSoapAndRestEntity;
  8. use Magento\TestModule5\Service\V2\Entity\AllSoapAndRestFactory;
  9. class AllSoapAndRest implements AllSoapAndRestInterface
  10. {
  11. /**
  12. * @var AllSoapAndRestFactory
  13. */
  14. protected $factory;
  15. /**
  16. * @param AllSoapAndRestFactory $factory
  17. */
  18. public function __construct(AllSoapAndRestFactory $factory)
  19. {
  20. $this->factory = $factory;
  21. }
  22. /**
  23. * @inheritdoc
  24. */
  25. public function item($id)
  26. {
  27. return $this->factory->create()->setPrice(1)->setId($id)->setName('testItemName');
  28. }
  29. /**
  30. * @inheritdoc
  31. */
  32. public function items()
  33. {
  34. $allSoapAndRest1 = $this->factory->create()->setPrice(1)->setId(1)->setName('testProduct1');
  35. $allSoapAndRest2 = $this->factory->create()->setPrice(1)->setId(2)->setName('testProduct2');
  36. return [$allSoapAndRest1, $allSoapAndRest2];
  37. }
  38. /**
  39. * @inheritdoc
  40. */
  41. public function create(\Magento\TestModule5\Service\V2\Entity\AllSoapAndRest $item)
  42. {
  43. return $this->factory->create()->setPrice($item->getPrice());
  44. }
  45. /**
  46. * @inheritdoc
  47. */
  48. public function update(\Magento\TestModule5\Service\V2\Entity\AllSoapAndRest $item)
  49. {
  50. $item->setName('Updated' . $item->getName());
  51. return $item;
  52. }
  53. /**
  54. * @param string $id
  55. * @return AllSoapAndRestEntity
  56. * @throws \Magento\Framework\Webapi\Exception
  57. */
  58. public function delete($id)
  59. {
  60. return $this->factory->create()->setPrice(1)->setId($id)->setName('testItemName');
  61. }
  62. }