Comment.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Model\Order\Shipment;
  7. use Magento\Framework\Api\AttributeValueFactory;
  8. use Magento\Sales\Api\Data\ShipmentCommentInterface;
  9. use Magento\Sales\Model\AbstractModel;
  10. class Comment extends AbstractModel implements ShipmentCommentInterface
  11. {
  12. /**
  13. * Shipment instance
  14. *
  15. * @var \Magento\Sales\Model\Order\Shipment
  16. */
  17. protected $_shipment;
  18. /**
  19. * @var \Magento\Store\Model\StoreManagerInterface
  20. */
  21. protected $_storeManager;
  22. /**
  23. * @param \Magento\Framework\Model\Context $context
  24. * @param \Magento\Framework\Registry $registry
  25. * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
  26. * @param AttributeValueFactory $customAttributeFactory
  27. * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  28. * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
  29. * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
  30. * @param array $data
  31. * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  32. */
  33. public function __construct(
  34. \Magento\Framework\Model\Context $context,
  35. \Magento\Framework\Registry $registry,
  36. \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
  37. AttributeValueFactory $customAttributeFactory,
  38. \Magento\Store\Model\StoreManagerInterface $storeManager,
  39. \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
  40. \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
  41. array $data = []
  42. ) {
  43. parent::__construct(
  44. $context,
  45. $registry,
  46. $extensionFactory,
  47. $customAttributeFactory,
  48. $resource,
  49. $resourceCollection,
  50. $data
  51. );
  52. $this->_storeManager = $storeManager;
  53. }
  54. /**
  55. * Initialize resource model
  56. *
  57. * @return void
  58. */
  59. protected function _construct()
  60. {
  61. $this->_init(\Magento\Sales\Model\ResourceModel\Order\Shipment\Comment::class);
  62. }
  63. /**
  64. * Declare Shipment instance
  65. *
  66. * @codeCoverageIgnore
  67. *
  68. * @param \Magento\Sales\Model\Order\Shipment $shipment
  69. * @return $this
  70. */
  71. public function setShipment(\Magento\Sales\Model\Order\Shipment $shipment)
  72. {
  73. $this->_shipment = $shipment;
  74. return $this;
  75. }
  76. /**
  77. * Retrieve Shipment instance
  78. *
  79. * @codeCoverageIgnore
  80. *
  81. * @return \Magento\Sales\Model\Order\Shipment
  82. */
  83. public function getShipment()
  84. {
  85. return $this->_shipment;
  86. }
  87. /**
  88. * Get store object
  89. *
  90. * @return \Magento\Store\Model\Store
  91. */
  92. public function getStore()
  93. {
  94. if ($this->getShipment()) {
  95. return $this->getShipment()->getStore();
  96. }
  97. return $this->_storeManager->getStore();
  98. }
  99. //@codeCoverageIgnoreStart
  100. /**
  101. * Returns comment
  102. *
  103. * @return string
  104. */
  105. public function getComment()
  106. {
  107. return $this->getData(ShipmentCommentInterface::COMMENT);
  108. }
  109. /**
  110. * Returns created_at
  111. *
  112. * @return string
  113. */
  114. public function getCreatedAt()
  115. {
  116. return $this->getData(ShipmentCommentInterface::CREATED_AT);
  117. }
  118. /**
  119. * {@inheritdoc}
  120. */
  121. public function setCreatedAt($createdAt)
  122. {
  123. return $this->setData(ShipmentCommentInterface::CREATED_AT, $createdAt);
  124. }
  125. /**
  126. * Returns is_customer_notified
  127. *
  128. * @return int
  129. */
  130. public function getIsCustomerNotified()
  131. {
  132. return $this->getData(ShipmentCommentInterface::IS_CUSTOMER_NOTIFIED);
  133. }
  134. /**
  135. * Returns is_visible_on_front
  136. *
  137. * @return int
  138. */
  139. public function getIsVisibleOnFront()
  140. {
  141. return $this->getData(ShipmentCommentInterface::IS_VISIBLE_ON_FRONT);
  142. }
  143. /**
  144. * Returns parent_id
  145. *
  146. * @return int
  147. */
  148. public function getParentId()
  149. {
  150. return $this->getData(ShipmentCommentInterface::PARENT_ID);
  151. }
  152. /**
  153. * {@inheritdoc}
  154. */
  155. public function setParentId($id)
  156. {
  157. return $this->setData(ShipmentCommentInterface::PARENT_ID, $id);
  158. }
  159. /**
  160. * {@inheritdoc}
  161. */
  162. public function setIsCustomerNotified($isCustomerNotified)
  163. {
  164. return $this->setData(ShipmentCommentInterface::IS_CUSTOMER_NOTIFIED, $isCustomerNotified);
  165. }
  166. /**
  167. * {@inheritdoc}
  168. */
  169. public function setIsVisibleOnFront($isVisibleOnFront)
  170. {
  171. return $this->setData(ShipmentCommentInterface::IS_VISIBLE_ON_FRONT, $isVisibleOnFront);
  172. }
  173. /**
  174. * {@inheritdoc}
  175. */
  176. public function setComment($comment)
  177. {
  178. return $this->setData(ShipmentCommentInterface::COMMENT, $comment);
  179. }
  180. /**
  181. * {@inheritdoc}
  182. *
  183. * @return \Magento\Sales\Api\Data\ShipmentCommentExtensionInterface|null
  184. */
  185. public function getExtensionAttributes()
  186. {
  187. return $this->_getExtensionAttributes();
  188. }
  189. /**
  190. * {@inheritdoc}
  191. *
  192. * @param \Magento\Sales\Api\Data\ShipmentCommentExtensionInterface $extensionAttributes
  193. * @return $this
  194. */
  195. public function setExtensionAttributes(
  196. \Magento\Sales\Api\Data\ShipmentCommentExtensionInterface $extensionAttributes
  197. ) {
  198. return $this->_setExtensionAttributes($extensionAttributes);
  199. }
  200. //@codeCoverageIgnoreEnd
  201. }