123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?php
- namespace AliyunMNS\Model;
- use AliyunMNS\Constants;
- class SubscriptionAttributes
- {
- private $endpoint;
- private $strategy;
- private $contentFormat;
- # may change in AliyunMNS\Topic
- private $topicName;
- # the following attributes cannot be changed
- private $subscriptionName;
- private $topicOwner;
- private $createTime;
- private $lastModifyTime;
- public function __construct(
- $subscriptionName = NULL,
- $endpoint = NULL,
- $strategy = NULL,
- $contentFormat = NULL,
- $topicName = NULL,
- $topicOwner = NULL,
- $createTime = NULL,
- $lastModifyTime = NULL)
- {
- $this->endpoint = $endpoint;
- $this->strategy = $strategy;
- $this->contentFormat = $contentFormat;
- $this->subscriptionName = $subscriptionName;
- //cloud change in AliyunMNS\Topic
- $this->topicName = $topicName;
- $this->topicOwner = $topicOwner;
- $this->createTime = $createTime;
- $this->lastModifyTime = $lastModifyTime;
- }
-
- public function getEndpoint()
- {
- return $this->endpoint;
- }
- public function setEndpoint($endpoint)
- {
- $this->endpoint = $endpoint;
- }
- public function getStrategy()
- {
- return $this->strategy;
- }
- public function setStrategy($strategy)
- {
- $this->strategy = $strategy;
- }
- public function getContentFormat()
- {
- return $this->contentFormat;
- }
- public function setContentFormat($contentFormat)
- {
- $this->contentFormat = $contentFormat;
- }
- public function getTopicName()
- {
- return $this->topicName;
- }
- public function setTopicName($topicName)
- {
- $this->topicName = $topicName;
- }
- public function getTopicOwner()
- {
- return $this->topicOwner;
- }
- public function getSubscriptionName()
- {
- return $this->subscriptionName;
- }
- public function getCreateTime()
- {
- return $this->createTime;
- }
- public function getLastModifyTime()
- {
- return $this->lastModifyTime;
- }
- public function writeXML(\XMLWriter $xmlWriter)
- {
- if ($this->endpoint != NULL)
- {
- $xmlWriter->writeElement(Constants::ENDPOINT, $this->endpoint);
- }
- if ($this->strategy != NULL)
- {
- $xmlWriter->writeElement(Constants::STRATEGY, $this->strategy);
- }
- if ($this->contentFormat != NULL)
- {
- $xmlWriter->writeElement(Constants::CONTENT_FORMAT, $this->contentFormat);
- }
- }
- static public function fromXML(\XMLReader $xmlReader)
- {
- $endpoint = NULL;
- $strategy = NULL;
- $contentFormat = NULL;
- $topicOwner = NULL;
- $topicName = NULL;
- $createTime = NULL;
- $lastModifyTime = NULL;
- while ($xmlReader->read())
- {
- if ($xmlReader->nodeType == \XMLReader::ELEMENT)
- {
- switch ($xmlReader->name) {
- case 'TopicOwner':
- $xmlReader->read();
- if ($xmlReader->nodeType == \XMLReader::TEXT)
- {
- $topicOwner = $xmlReader->value;
- }
- break;
- case 'TopicName':
- $xmlReader->read();
- if ($xmlReader->nodeType == \XMLReader::TEXT)
- {
- $topicName = $xmlReader->value;
- }
- break;
- case 'SubscriptionName':
- $xmlReader->read();
- if ($xmlReader->nodeType == \XMLReader::TEXT)
- {
- $subscriptionName = $xmlReader->value;
- }
- case 'Endpoint':
- $xmlReader->read();
- if ($xmlReader->nodeType == \XMLReader::TEXT)
- {
- $endpoint = $xmlReader->value;
- }
- break;
- case 'NotifyStrategy':
- $xmlReader->read();
- if ($xmlReader->nodeType == \XMLReader::TEXT)
- {
- $strategy = $xmlReader->value;
- }
- break;
- case 'NotifyContentFormat':
- $xmlReader->read();
- if ($xmlReader->nodeType == \XMLReader::TEXT)
- {
- $contentFormat = $xmlReader->value;
- }
- break;
- case 'CreateTime':
- $xmlReader->read();
- if ($xmlReader->nodeType == \XMLReader::TEXT)
- {
- $createTime = $xmlReader->value;
- }
- break;
- case 'LastModifyTime':
- $xmlReader->read();
- if ($xmlReader->nodeType == \XMLReader::TEXT)
- {
- $lastModifyTime = $xmlReader->value;
- }
- break;
- }
- }
- }
- $attributes = new SubscriptionAttributes(
- $subscriptionName,
- $endpoint,
- $strategy,
- $contentFormat,
- $topicName,
- $topicOwner,
- $createTime,
- $lastModifyTime);
- return $attributes;
- }
- }
- ?>
|