Bez popisu

SetTopicAttributeRequest.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace AliyunMNS\Requests;
  3. use AliyunMNS\Constants;
  4. use AliyunMNS\Requests\BaseRequest;
  5. use AliyunMNS\Model\TopicAttributes;
  6. class SetTopicAttributeRequest extends BaseRequest
  7. {
  8. private $topicName;
  9. private $attributes;
  10. public function __construct($topicName, TopicAttributes $attributes = NULL)
  11. {
  12. parent::__construct('put', 'topics/' . $topicName . '?metaoverride=true');
  13. if ($attributes == NULL)
  14. {
  15. $attributes = new TopicAttributes();
  16. }
  17. $this->topicName = $topicName;
  18. $this->attributes = $attributes;
  19. }
  20. public function getTopicName()
  21. {
  22. return $this->topicName;
  23. }
  24. public function getTopicAttributes()
  25. {
  26. return $this->attributes;
  27. }
  28. public function generateBody()
  29. {
  30. $xmlWriter = new \XMLWriter;
  31. $xmlWriter->openMemory();
  32. $xmlWriter->startDocument("1.0", "UTF-8");
  33. $xmlWriter->startElementNS(NULL, "Topic", Constants::MNS_XML_NAMESPACE);
  34. $this->attributes->writeXML($xmlWriter);
  35. $xmlWriter->endElement();
  36. $xmlWriter->endDocument();
  37. return $xmlWriter->outputMemory();
  38. }
  39. public function generateQueryString()
  40. {
  41. return NULL;
  42. }
  43. }
  44. ?>