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