No Description

MessagePropertiesForSend.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace AliyunMNS\Traits;
  3. use AliyunMNS\Constants;
  4. trait MessagePropertiesForSend
  5. {
  6. protected $messageBody;
  7. protected $delaySeconds;
  8. protected $priority;
  9. public function getMessageBody()
  10. {
  11. return $this->messageBody;
  12. }
  13. public function setMessageBody($messageBody)
  14. {
  15. $this->messageBody = $messageBody;
  16. }
  17. public function getDelaySeconds()
  18. {
  19. return $this->delaySeconds;
  20. }
  21. public function setDelaySeconds($delaySeconds)
  22. {
  23. $this->delaySeconds = $delaySeconds;
  24. }
  25. public function getPriority()
  26. {
  27. return $this->priority;
  28. }
  29. public function setPriority($priority)
  30. {
  31. $this->priority = $priority;
  32. }
  33. public function writeMessagePropertiesForSendXML(\XMLWriter $xmlWriter, $base64)
  34. {
  35. if ($this->messageBody != NULL)
  36. {
  37. if ($base64 == TRUE) {
  38. $xmlWriter->writeElement(Constants::MESSAGE_BODY, base64_encode($this->messageBody));
  39. } else {
  40. $xmlWriter->writeElement(Constants::MESSAGE_BODY, $this->messageBody);
  41. }
  42. }
  43. if ($this->delaySeconds != NULL)
  44. {
  45. $xmlWriter->writeElement(Constants::DELAY_SECONDS, $this->delaySeconds);
  46. }
  47. if ($this->priority !== NULL)
  48. {
  49. $xmlWriter->writeElement(Constants::PRIORITY, $this->priority);
  50. }
  51. }
  52. }
  53. ?>