Ei kuvausta

SubscriptionAttributes.php 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. namespace AliyunMNS\Model;
  3. use AliyunMNS\Constants;
  4. class SubscriptionAttributes
  5. {
  6. private $endpoint;
  7. private $strategy;
  8. private $contentFormat;
  9. # may change in AliyunMNS\Topic
  10. private $topicName;
  11. # the following attributes cannot be changed
  12. private $subscriptionName;
  13. private $topicOwner;
  14. private $createTime;
  15. private $lastModifyTime;
  16. public function __construct(
  17. $subscriptionName = NULL,
  18. $endpoint = NULL,
  19. $strategy = NULL,
  20. $contentFormat = NULL,
  21. $topicName = NULL,
  22. $topicOwner = NULL,
  23. $createTime = NULL,
  24. $lastModifyTime = NULL)
  25. {
  26. $this->endpoint = $endpoint;
  27. $this->strategy = $strategy;
  28. $this->contentFormat = $contentFormat;
  29. $this->subscriptionName = $subscriptionName;
  30. //cloud change in AliyunMNS\Topic
  31. $this->topicName = $topicName;
  32. $this->topicOwner = $topicOwner;
  33. $this->createTime = $createTime;
  34. $this->lastModifyTime = $lastModifyTime;
  35. }
  36. public function getEndpoint()
  37. {
  38. return $this->endpoint;
  39. }
  40. public function setEndpoint($endpoint)
  41. {
  42. $this->endpoint = $endpoint;
  43. }
  44. public function getStrategy()
  45. {
  46. return $this->strategy;
  47. }
  48. public function setStrategy($strategy)
  49. {
  50. $this->strategy = $strategy;
  51. }
  52. public function getContentFormat()
  53. {
  54. return $this->contentFormat;
  55. }
  56. public function setContentFormat($contentFormat)
  57. {
  58. $this->contentFormat = $contentFormat;
  59. }
  60. public function getTopicName()
  61. {
  62. return $this->topicName;
  63. }
  64. public function setTopicName($topicName)
  65. {
  66. $this->topicName = $topicName;
  67. }
  68. public function getTopicOwner()
  69. {
  70. return $this->topicOwner;
  71. }
  72. public function getSubscriptionName()
  73. {
  74. return $this->subscriptionName;
  75. }
  76. public function getCreateTime()
  77. {
  78. return $this->createTime;
  79. }
  80. public function getLastModifyTime()
  81. {
  82. return $this->lastModifyTime;
  83. }
  84. public function writeXML(\XMLWriter $xmlWriter)
  85. {
  86. if ($this->endpoint != NULL)
  87. {
  88. $xmlWriter->writeElement(Constants::ENDPOINT, $this->endpoint);
  89. }
  90. if ($this->strategy != NULL)
  91. {
  92. $xmlWriter->writeElement(Constants::STRATEGY, $this->strategy);
  93. }
  94. if ($this->contentFormat != NULL)
  95. {
  96. $xmlWriter->writeElement(Constants::CONTENT_FORMAT, $this->contentFormat);
  97. }
  98. }
  99. static public function fromXML(\XMLReader $xmlReader)
  100. {
  101. $endpoint = NULL;
  102. $strategy = NULL;
  103. $contentFormat = NULL;
  104. $topicOwner = NULL;
  105. $topicName = NULL;
  106. $createTime = NULL;
  107. $lastModifyTime = NULL;
  108. while ($xmlReader->read())
  109. {
  110. if ($xmlReader->nodeType == \XMLReader::ELEMENT)
  111. {
  112. switch ($xmlReader->name) {
  113. case 'TopicOwner':
  114. $xmlReader->read();
  115. if ($xmlReader->nodeType == \XMLReader::TEXT)
  116. {
  117. $topicOwner = $xmlReader->value;
  118. }
  119. break;
  120. case 'TopicName':
  121. $xmlReader->read();
  122. if ($xmlReader->nodeType == \XMLReader::TEXT)
  123. {
  124. $topicName = $xmlReader->value;
  125. }
  126. break;
  127. case 'SubscriptionName':
  128. $xmlReader->read();
  129. if ($xmlReader->nodeType == \XMLReader::TEXT)
  130. {
  131. $subscriptionName = $xmlReader->value;
  132. }
  133. case 'Endpoint':
  134. $xmlReader->read();
  135. if ($xmlReader->nodeType == \XMLReader::TEXT)
  136. {
  137. $endpoint = $xmlReader->value;
  138. }
  139. break;
  140. case 'NotifyStrategy':
  141. $xmlReader->read();
  142. if ($xmlReader->nodeType == \XMLReader::TEXT)
  143. {
  144. $strategy = $xmlReader->value;
  145. }
  146. break;
  147. case 'NotifyContentFormat':
  148. $xmlReader->read();
  149. if ($xmlReader->nodeType == \XMLReader::TEXT)
  150. {
  151. $contentFormat = $xmlReader->value;
  152. }
  153. break;
  154. case 'CreateTime':
  155. $xmlReader->read();
  156. if ($xmlReader->nodeType == \XMLReader::TEXT)
  157. {
  158. $createTime = $xmlReader->value;
  159. }
  160. break;
  161. case 'LastModifyTime':
  162. $xmlReader->read();
  163. if ($xmlReader->nodeType == \XMLReader::TEXT)
  164. {
  165. $lastModifyTime = $xmlReader->value;
  166. }
  167. break;
  168. }
  169. }
  170. }
  171. $attributes = new SubscriptionAttributes(
  172. $subscriptionName,
  173. $endpoint,
  174. $strategy,
  175. $contentFormat,
  176. $topicName,
  177. $topicOwner,
  178. $createTime,
  179. $lastModifyTime);
  180. return $attributes;
  181. }
  182. }
  183. ?>