Comment.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Model\Order\Invoice;
  7. use Magento\Framework\Api\AttributeValueFactory;
  8. use Magento\Sales\Api\Data\InvoiceCommentInterface;
  9. use Magento\Sales\Model\AbstractModel;
  10. class Comment extends AbstractModel implements InvoiceCommentInterface
  11. {
  12. /**
  13. * Invoice instance
  14. *
  15. * @var \Magento\Sales\Model\Order\Invoice
  16. */
  17. protected $_invoice;
  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\Invoice\Comment::class);
  62. }
  63. /**
  64. * Declare invoice instance
  65. *
  66. * @param \Magento\Sales\Model\Order\Invoice $invoice
  67. * @return $this
  68. */
  69. public function setInvoice(\Magento\Sales\Model\Order\Invoice $invoice)
  70. {
  71. $this->_invoice = $invoice;
  72. return $this;
  73. }
  74. /**
  75. * Retrieve invoice instance
  76. *
  77. * @return \Magento\Sales\Model\Order\Invoice
  78. */
  79. public function getInvoice()
  80. {
  81. return $this->_invoice;
  82. }
  83. /**
  84. * Get store object
  85. *
  86. * @return \Magento\Store\Model\Store
  87. */
  88. public function getStore()
  89. {
  90. if ($this->getInvoice()) {
  91. return $this->getInvoice()->getStore();
  92. }
  93. return $this->_storeManager->getStore();
  94. }
  95. /**
  96. * Returns comment
  97. *
  98. * @return string
  99. */
  100. public function getComment()
  101. {
  102. return $this->getData(InvoiceCommentInterface::COMMENT);
  103. }
  104. /**
  105. * Returns created_at
  106. *
  107. * @return string
  108. */
  109. public function getCreatedAt()
  110. {
  111. return $this->getData(InvoiceCommentInterface::CREATED_AT);
  112. }
  113. /**
  114. * {@inheritdoc}
  115. */
  116. public function setCreatedAt($createdAt)
  117. {
  118. return $this->setData(InvoiceCommentInterface::CREATED_AT, $createdAt);
  119. }
  120. /**
  121. * Returns is_customer_notified
  122. *
  123. * @return int
  124. */
  125. public function getIsCustomerNotified()
  126. {
  127. return $this->getData(InvoiceCommentInterface::IS_CUSTOMER_NOTIFIED);
  128. }
  129. /**
  130. * Returns is_visible_on_front
  131. *
  132. * @return int
  133. */
  134. public function getIsVisibleOnFront()
  135. {
  136. return $this->getData(InvoiceCommentInterface::IS_VISIBLE_ON_FRONT);
  137. }
  138. /**
  139. * Returns parent_id
  140. *
  141. * @return int
  142. */
  143. public function getParentId()
  144. {
  145. return $this->getData(InvoiceCommentInterface::PARENT_ID);
  146. }
  147. //@codeCoverageIgnoreStart
  148. /**
  149. * {@inheritdoc}
  150. */
  151. public function setParentId($id)
  152. {
  153. return $this->setData(InvoiceCommentInterface::PARENT_ID, $id);
  154. }
  155. /**
  156. * {@inheritdoc}
  157. */
  158. public function setIsCustomerNotified($isCustomerNotified)
  159. {
  160. return $this->setData(InvoiceCommentInterface::IS_CUSTOMER_NOTIFIED, $isCustomerNotified);
  161. }
  162. /**
  163. * {@inheritdoc}
  164. */
  165. public function setIsVisibleOnFront($isVisibleOnFront)
  166. {
  167. return $this->setData(InvoiceCommentInterface::IS_VISIBLE_ON_FRONT, $isVisibleOnFront);
  168. }
  169. /**
  170. * {@inheritdoc}
  171. */
  172. public function setComment($comment)
  173. {
  174. return $this->setData(InvoiceCommentInterface::COMMENT, $comment);
  175. }
  176. /**
  177. * {@inheritdoc}
  178. *
  179. * @return \Magento\Sales\Api\Data\InvoiceCommentExtensionInterface|null
  180. */
  181. public function getExtensionAttributes()
  182. {
  183. return $this->_getExtensionAttributes();
  184. }
  185. /**
  186. * {@inheritdoc}
  187. *
  188. * @param \Magento\Sales\Api\Data\InvoiceCommentExtensionInterface $extensionAttributes
  189. * @return $this
  190. */
  191. public function setExtensionAttributes(
  192. \Magento\Sales\Api\Data\InvoiceCommentExtensionInterface $extensionAttributes
  193. ) {
  194. return $this->_setExtensionAttributes($extensionAttributes);
  195. }
  196. //@codeCoverageIgnoreEnd
  197. }