SalesEvent.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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\InventorySales\Model;
  8. use Magento\InventorySalesApi\Api\Data\SalesEventInterface;
  9. use Magento\Framework\Model\AbstractExtensibleModel;
  10. use Magento\InventorySalesApi\Api\Data\SalesEventExtensionInterface;
  11. /**
  12. * @inheritdoc
  13. */
  14. class SalesEvent extends AbstractExtensibleModel implements SalesEventInterface
  15. {
  16. /**
  17. * @var string
  18. */
  19. private $type;
  20. /**
  21. * @var string
  22. */
  23. private $objectType;
  24. /**
  25. * @var string
  26. */
  27. private $objectId;
  28. /**
  29. * SalesEvent constructor.
  30. * @param \Magento\Framework\Model\Context $context
  31. * @param \Magento\Framework\Registry $registry
  32. * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
  33. * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory
  34. * @param string $type
  35. * @param string $objectType
  36. * @param string $objectId
  37. * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
  38. * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
  39. * @param array $data
  40. * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  41. */
  42. public function __construct(
  43. \Magento\Framework\Model\Context $context,
  44. \Magento\Framework\Registry $registry,
  45. \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
  46. \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory,
  47. string $type,
  48. string $objectType,
  49. string $objectId,
  50. \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
  51. \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
  52. array $data = []
  53. ) {
  54. parent::__construct(
  55. $context,
  56. $registry,
  57. $extensionFactory,
  58. $customAttributeFactory,
  59. $resource,
  60. $resourceCollection,
  61. $data
  62. );
  63. $this->type = $type;
  64. $this->objectType = $objectType;
  65. $this->objectId = $objectId;
  66. }
  67. /**
  68. * @inheritdoc
  69. */
  70. public function getType(): string
  71. {
  72. return $this->type;
  73. }
  74. /**
  75. * @inheritdoc
  76. */
  77. public function getObjectType(): string
  78. {
  79. return $this->objectType;
  80. }
  81. /**
  82. * @inheritdoc
  83. */
  84. public function getObjectId(): string
  85. {
  86. return $this->objectId;
  87. }
  88. /**
  89. * @inheritdoc
  90. */
  91. public function getExtensionAttributes(): ?SalesEventExtensionInterface
  92. {
  93. $extensionAttributes = $this->_getExtensionAttributes();
  94. if (null === $extensionAttributes) {
  95. $extensionAttributes = $this->extensionAttributesFactory->create(SalesEventInterface::class);
  96. $this->setExtensionAttributes($extensionAttributes);
  97. }
  98. return $extensionAttributes;
  99. }
  100. /**
  101. * @inheritdoc
  102. */
  103. public function setExtensionAttributes(SalesEventExtensionInterface $extensionAttributes): void
  104. {
  105. $this->_setExtensionAttributes($extensionAttributes);
  106. }
  107. }