NoWebApiXml.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\TestModule2\Service\V1;
  7. use Magento\TestModule2\Service\V1\Entity\Item;
  8. use Magento\TestModule2\Service\V1\Entity\ItemFactory;
  9. class NoWebApiXml implements \Magento\TestModule2\Service\V1\NoWebApiXmlInterface
  10. {
  11. /**
  12. * @var ItemFactory
  13. */
  14. protected $itemFactory;
  15. /**
  16. * @param ItemFactory $itemFactory
  17. */
  18. public function __construct(ItemFactory $itemFactory)
  19. {
  20. $this->itemFactory = $itemFactory;
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function item($id)
  26. {
  27. return $this->itemFactory->create()->setId($id)->setName('testProduct1');
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function items()
  33. {
  34. $result1 = $this->itemFactory->create()->setId(1)->setName('testProduct1');
  35. $result2 = $this->itemFactory->create()->setId(2)->setName('testProduct2');
  36. return [$result1, $result2];
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function create($name)
  42. {
  43. return $this->itemFactory->create()->setId(rand())->setName($name);
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public function update(Item $item)
  49. {
  50. return $this->itemFactory->create()->setId($item->getId())->setName('Updated' . $item->getName());
  51. }
  52. }