1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Acquia\LiftClient\Entity; |
4
|
|
|
|
5
|
|
|
use DateTime; |
6
|
|
|
use Symfony\Component\Serializer\Serializer; |
7
|
|
|
use Symfony\Component\Serializer\Encoder\JsonEncoder; |
8
|
|
|
use Symfony\Component\Serializer\Normalizer\CustomNormalizer; |
9
|
|
|
|
10
|
|
|
class Slot extends \ArrayObject |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @param array $array |
15
|
|
|
*/ |
16
|
|
|
public function __construct(array $array = []) |
17
|
|
|
{ |
18
|
|
|
parent::__construct($array); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Sets the 'id' parameter. |
23
|
|
|
* |
24
|
|
|
* @param string $id |
25
|
|
|
* |
26
|
|
|
* @return \Acquia\LiftClient\Entity\Slot |
27
|
|
|
*/ |
28
|
|
|
public function setId($id) |
29
|
|
|
{ |
30
|
|
|
$this['id'] = $id; |
31
|
|
|
|
32
|
|
|
return $this; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Gets the 'id' parameter. |
37
|
|
|
* |
38
|
|
|
* @return string |
39
|
|
|
*/ |
40
|
|
|
public function getId() |
41
|
|
|
{ |
42
|
|
|
return $this->getValue('id', ''); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Sets the 'label' parameter. |
47
|
|
|
* |
48
|
|
|
* @param string $label |
49
|
|
|
* |
50
|
|
|
* @return \Acquia\LiftClient\Entity\Slot |
51
|
|
|
*/ |
52
|
|
|
public function setLabel($label) |
53
|
|
|
{ |
54
|
|
|
$this['label'] = $label; |
55
|
|
|
|
56
|
|
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Gets the 'id' parameter. |
61
|
|
|
* |
62
|
|
|
* @return string |
63
|
|
|
*/ |
64
|
|
|
public function getLabel() |
65
|
|
|
{ |
66
|
|
|
return $this->getValue('label', ''); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Sets the 'description' parameter. |
71
|
|
|
* |
72
|
|
|
* @param string $description |
73
|
|
|
* |
74
|
|
|
* @return \Acquia\LiftClient\Entity\Slot |
75
|
|
|
*/ |
76
|
|
|
public function setDescription($description) |
77
|
|
|
{ |
78
|
|
|
$this['description'] = $description; |
79
|
|
|
|
80
|
|
|
return $this; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Gets the 'description' parameter. |
85
|
|
|
* |
86
|
|
|
* @return string |
87
|
|
|
*/ |
88
|
|
|
public function getDescription() |
89
|
|
|
{ |
90
|
|
|
return $this->getValue('description', ''); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Sets the 'html' parameter. |
95
|
|
|
* |
96
|
|
|
* @param string $html |
97
|
|
|
* |
98
|
|
|
* @return \Acquia\LiftClient\Entity\Slot |
99
|
|
|
*/ |
100
|
|
|
public function setHtml($html) |
101
|
|
|
{ |
102
|
|
|
$this['html'] = $html; |
103
|
|
|
|
104
|
|
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Gets the 'html' parameter. |
109
|
|
|
* |
110
|
|
|
* @return string |
111
|
|
|
*/ |
112
|
|
|
public function getHtml() |
113
|
|
|
{ |
114
|
|
|
return $this->getValue('html', ''); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Sets the 'status' parameter. |
119
|
|
|
* |
120
|
|
|
* @param bool $status |
121
|
|
|
* |
122
|
|
|
* @return \Acquia\LiftClient\Entity\Slot |
123
|
|
|
*/ |
124
|
|
|
public function setStatus($status) |
125
|
|
|
{ |
126
|
|
|
if ($status === true) { |
127
|
|
|
$this['status'] = 'enabled'; |
128
|
|
|
} else { |
129
|
|
|
$this['status'] = 'disabled'; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
return $this; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Gets the 'status' parameter. |
137
|
|
|
* |
138
|
|
|
* @return bool |
139
|
|
|
*/ |
140
|
|
|
public function getStatus() |
141
|
|
|
{ |
142
|
|
|
$status = $this->getValue('status', ''); |
143
|
|
|
if ($status == 'enabled') { |
144
|
|
|
return true; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
return false; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Sets the 'visibility' parameter. |
152
|
|
|
* |
153
|
|
|
* @param \Acquia\LiftClient\Entity\Visibility $visibility |
154
|
|
|
* |
155
|
|
|
* @return \Acquia\LiftClient\Entity\Slot |
156
|
|
|
*/ |
157
|
|
|
public function setVisibility(Visibility $visibility) |
158
|
|
|
{ |
159
|
|
|
// We need to 'normalize' so that we stay with arrays. Annoying stuff. |
160
|
|
|
$this['visibility'] = $visibility->getArrayCopy(); |
161
|
|
|
|
162
|
|
|
return $this; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Gets the 'visibility' parameter. |
167
|
|
|
* |
168
|
|
|
* @return string |
169
|
|
|
*/ |
170
|
|
|
public function getVisibility() |
171
|
|
|
{ |
172
|
|
|
$visibility = $this->getValue('visibility', ''); |
173
|
|
|
|
174
|
|
|
return new \Acquia\LiftClient\Entity\Visibility($visibility); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Gets the 'created' parameter. |
179
|
|
|
* |
180
|
|
|
* @return DateTime |
181
|
|
|
*/ |
182
|
|
|
public function getCreated() |
183
|
|
|
{ |
184
|
|
|
$date = $this->getValue('created', ''); |
185
|
|
|
$datetime = DateTime::createFromFormat(DateTime::ISO8601, $date); |
|
|
|
|
186
|
|
|
|
187
|
|
|
return $datetime; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Gets the 'updated' parameter. |
192
|
|
|
* |
193
|
|
|
* @return DateTime |
194
|
|
|
*/ |
195
|
|
|
public function getUpdated() |
196
|
|
|
{ |
197
|
|
|
$date = $this->getValue('updated', ''); |
198
|
|
|
$datetime = DateTime::createFromFormat(DateTime::ISO8601, $date); |
|
|
|
|
199
|
|
|
|
200
|
|
|
return $datetime; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Returns the json representation of the current object. |
205
|
|
|
* |
206
|
|
|
* @return string |
207
|
|
|
*/ |
208
|
|
|
public function json() |
209
|
|
|
{ |
210
|
|
|
$encoders = array(new JsonEncoder()); |
211
|
|
|
$normalizers = array(new CustomNormalizer()); |
212
|
|
|
$serializer = new Serializer($normalizers, $encoders); |
213
|
|
|
|
214
|
|
|
return $serializer->serialize($this, 'json'); |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* |
219
|
|
|
* @param string $key |
220
|
|
|
* @param string $default |
221
|
|
|
* |
222
|
|
|
* @return mixed |
223
|
|
|
*/ |
224
|
|
|
protected function getValue($key, $default) |
225
|
|
|
{ |
226
|
|
|
return isset($this[$key]) ? $this[$key] : $default; |
227
|
|
|
} |
228
|
|
|
} |
229
|
|
|
|