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