]> Raphaël G. Git Repositories - airbundle/blob - Entity/Location.php
Add hat field
[airbundle] / Entity / Location.php
1 <?php declare(strict_types=1);
2
3 /*
4 * this file is part of the rapsys packbundle package.
5 *
6 * (c) raphaël gertz <symfony@rapsys.eu>
7 *
8 * for the full copyright and license information, please view the license
9 * file that was distributed with this source code.
10 */
11
12 namespace Rapsys\AirBundle\Entity;
13
14 use Doctrine\Common\Collections\ArrayCollection;
15 use Doctrine\ORM\Event\PreUpdateEventArgs;
16
17 /**
18 * Location
19 */
20 class Location {
21 /**
22 * @var integer
23 */
24 private $id;
25
26 /**
27 * @var string
28 */
29 private $title;
30
31 /**
32 * @var string
33 */
34 private $address;
35
36 /**
37 * @var string
38 */
39 private $zipcode;
40
41 /**
42 * @var string
43 */
44 private $city;
45
46 /**
47 * @var string
48 */
49 private $latitude;
50
51 /**
52 * @var string
53 */
54 private $longitude;
55
56 /**
57 * @var boolean
58 */
59 private $hotspot;
60
61 /**
62 * @var \DateTime
63 */
64 private $created;
65
66 /**
67 * @var \DateTime
68 */
69 private $updated;
70
71 /**
72 * @var ArrayCollection
73 */
74 private $sessions;
75
76 /**
77 * @var ArrayCollection
78 */
79 private $snippets;
80
81 /**
82 * @var ArrayCollection
83 */
84 private $users;
85
86 /**
87 * Constructor
88 */
89 public function __construct() {
90 //Set defaults
91 $this->created = new \DateTime('now');
92 $this->updated = new \DateTime('now');
93 $this->sessions = new ArrayCollection();
94 $this->snippets = new ArrayCollection();
95 $this->users = new ArrayCollection();
96 }
97
98 /**
99 * Get id
100 *
101 * @return integer
102 */
103 public function getId(): int {
104 return $this->id;
105 }
106
107 /**
108 * Set title
109 *
110 * @param string $title
111 *
112 * @return Location
113 */
114 public function setTitle(string $title): Location {
115 $this->title = $title;
116
117 return $this;
118 }
119
120 /**
121 * Get title
122 *
123 * @return string
124 */
125 public function getTitle(): string {
126 return $this->title;
127 }
128
129 /**
130 * Set address
131 *
132 * @param string $address
133 *
134 * @return Location
135 */
136 public function setAddress(string $address): Location {
137 $this->address = $address;
138
139 return $this;
140 }
141
142 /**
143 * Get address
144 *
145 * @return string
146 */
147 public function getAddress(): string {
148 return $this->address;
149 }
150
151 /**
152 * Set zipcode
153 *
154 * @param string $zipcode
155 *
156 * @return Location
157 */
158 public function setZipcode(string $zipcode): Location {
159 $this->zipcode = $zipcode;
160
161 return $this;
162 }
163
164 /**
165 * Get zipcode
166 *
167 * @return string
168 */
169 public function getZipcode(): string {
170 return $this->zipcode;
171 }
172
173 /**
174 * Set city
175 *
176 * @param string $city
177 *
178 * @return Location
179 */
180 public function setCity(string $city): Location {
181 $this->city = $city;
182
183 return $this;
184 }
185
186 /**
187 * Get city
188 *
189 * @return string
190 */
191 public function getCity(): string {
192 return $this->city;
193 }
194
195 /**
196 * Set latitude
197 *
198 * @param string $latitude
199 *
200 * @return Location
201 */
202 public function setLatitude(string $latitude): Location {
203 $this->latitude = $latitude;
204
205 return $this;
206 }
207
208 /**
209 * Get latitude
210 *
211 * @return string
212 */
213 public function getLatitude(): string {
214 return $this->latitude;
215 }
216
217 /**
218 * Set longitude
219 *
220 * @param string $longitude
221 *
222 * @return Location
223 */
224 public function setLongitude(string $longitude): Location {
225 $this->longitude = $longitude;
226
227 return $this;
228 }
229
230 /**
231 * Get longitude
232 *
233 * @return string
234 */
235 public function getLongitude(): string {
236 return $this->longitude;
237 }
238
239 /**
240 * Set hotspot
241 *
242 * @param boolean $hotspot
243 *
244 * @return Session
245 */
246 public function setHotspot(bool $hotspot): Location {
247 $this->hotspot = $hotspot;
248
249 return $this;
250 }
251
252 /**
253 * Get hotspot
254 *
255 * @return boolean
256 */
257 public function getHotspot(): bool {
258 return $this->hotspot;
259 }
260
261 /**
262 * Set created
263 *
264 * @param \DateTime $created
265 *
266 * @return Location
267 */
268 public function setCreated(\DateTime $created): Location {
269 $this->created = $created;
270
271 return $this;
272 }
273
274 /**
275 * Get created
276 *
277 * @return \DateTime
278 */
279 public function getCreated(): \DateTime {
280 return $this->created;
281 }
282
283 /**
284 * Set updated
285 *
286 * @param \DateTime $updated
287 *
288 * @return Location
289 */
290 public function setUpdated(\DateTime $updated): Location {
291 $this->updated = $updated;
292
293 return $this;
294 }
295
296 /**
297 * Get updated
298 *
299 * @return \DateTime
300 */
301 public function getUpdated(): \DateTime {
302 return $this->updated;
303 }
304
305 /**
306 * Add session
307 *
308 * @param Session $session
309 *
310 * @return Location
311 */
312 public function addSession(Session $session): Location {
313 $this->sessions[] = $session;
314
315 return $this;
316 }
317
318 /**
319 * Remove session
320 *
321 * @param Session $session
322 * @return boolean
323 */
324 public function removeSession(Session $session): bool {
325 return $this->sessions->removeElement($session);
326 }
327
328 /**
329 * Get sessions
330 *
331 * @return ArrayCollection
332 */
333 public function getSessions(): ArrayCollection {
334 return $this->sessions;
335 }
336
337 /**
338 * Add snippet
339 *
340 * @param Snippet $snippet
341 *
342 * @return Location
343 */
344 public function addSnippet(Snippet $snippet): Location {
345 $this->snippets[] = $snippet;
346
347 return $this;
348 }
349
350 /**
351 * Remove snippet
352 *
353 * @param Snippet $snippet
354 * @return boolean
355 */
356 public function removeSnippet(Snippet $snippet): bool {
357 return $this->snippets->removeElement($snippet);
358 }
359
360 /**
361 * Get snippets
362 *
363 * @return ArrayCollection
364 */
365 public function getSnippets(): ArrayCollection {
366 return $this->snippets;
367 }
368
369 /**
370 * Add user
371 *
372 * @param User $user
373 *
374 * @return Location
375 */
376 public function addUser(User $user): Location {
377 $this->users[] = $user;
378
379 return $this;
380 }
381
382 /**
383 * Remove user
384 *
385 * @param User $user
386 * @return boolean
387 */
388 public function removeUser(User $user): bool {
389 return $this->users->removeElement($user);
390 }
391
392 /**
393 * Get users
394 *
395 * @return ArrayCollection
396 */
397 public function getUsers(): ArrayCollection {
398 return $this->users;
399 }
400
401 /**
402 * {@inheritdoc}
403 */
404 public function preUpdate(PreUpdateEventArgs $eventArgs) {
405 //Check that we have a location instance
406 if (($location = $eventArgs->getEntity()) instanceof Location) {
407 //Set updated value
408 $location->setUpdated(new \DateTime('now'));
409 }
410 }
411
412 /**
413 * Returns a string representation of the location
414 *
415 * @return string
416 */
417 public function __toString(): string {
418 return $this->title;
419 }
420 }