ItemStatus.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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\AsynchronousOperations\Model;
  8. use Magento\AsynchronousOperations\Api\Data\ItemStatusInterface;
  9. use Magento\Framework\DataObject;
  10. class ItemStatus extends DataObject implements ItemStatusInterface
  11. {
  12. /**
  13. * @inheritDoc
  14. */
  15. public function getId()
  16. {
  17. return $this->getData(self::ENTITY_ID);
  18. }
  19. /**
  20. * @inheritDoc
  21. */
  22. public function setId($entityId)
  23. {
  24. return $this->setData(self::ENTITY_ID, $entityId);
  25. }
  26. /**
  27. * @inheritDoc
  28. */
  29. public function getDataHash()
  30. {
  31. return $this->getData(self::DATA_HASH);
  32. }
  33. /**
  34. * @inheritDoc
  35. */
  36. public function setDataHash($hash)
  37. {
  38. return $this->setData(self::DATA_HASH, $hash);
  39. }
  40. /**
  41. * @inheritDoc
  42. */
  43. public function getStatus()
  44. {
  45. return $this->getData(self::STATUS);
  46. }
  47. /**
  48. * @inheritDoc
  49. */
  50. public function setStatus($status = self::STATUS_ACCEPTED)
  51. {
  52. return $this->setData(self::STATUS, $status);
  53. }
  54. /**
  55. * @inheritDoc
  56. */
  57. public function getErrorMessage()
  58. {
  59. return $this->getData(self::ERROR_MESSAGE);
  60. }
  61. /**
  62. * @inheritDoc
  63. */
  64. public function setErrorMessage($errorMessage = null)
  65. {
  66. if ($errorMessage instanceof \Exception) {
  67. $errorMessage = $errorMessage->getMessage();
  68. }
  69. return $this->setData(self::ERROR_MESSAGE, $errorMessage);
  70. }
  71. /**
  72. * @inheritDoc
  73. */
  74. public function getErrorCode()
  75. {
  76. return $this->getData(self::ERROR_CODE);
  77. }
  78. /**
  79. * @inheritDoc
  80. */
  81. public function setErrorCode($errorCode = null)
  82. {
  83. if ($errorCode instanceof \Exception) {
  84. $errorCode = $errorCode->getCode();
  85. }
  86. return $this->setData(self::ERROR_CODE, (int) $errorCode);
  87. }
  88. }