]> Raphaël G. Git Repositories - airbundle/blob - Entity/Location.php
Add 171 pixels logo
[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 protected $description;
35
36 /**
37 * @var string
38 */
39 private $address;
40
41 /**
42 * @var string
43 */
44 private $zipcode;
45
46 /**
47 * @var string
48 */
49 private $city;
50
51 /**
52 * @var string
53 */
54 private $latitude;
55
56 /**
57 * @var string
58 */
59 private $longitude;
60
61 /**
62 * @var bool
63 */
64 private $indoor;
65
66 /**
67 * @var bool
68 */
69 private $hotspot;
70
71 /**
72 * @var \DateTime
73 */
74 private $created;
75
76 /**
77 * @var \DateTime
78 */
79 private $updated;
80
81 /**
82 * @var ArrayCollection
83 */
84 private $sessions;
85
86 /**
87 * @var ArrayCollection
88 */
89 private $snippets;
90
91 /**
92 * @var ArrayCollection
93 */
94 private $users;
95
96 /**
97 * Constructor
98 */
99 public function __construct() {
100 //Set defaults
101 $this->description = null;
102 $this->created = new \DateTime('now');
103 $this->updated = new \DateTime('now');
104 $this->sessions = new ArrayCollection();
105 $this->snippets = new ArrayCollection();
106 $this->users = new ArrayCollection();
107 }
108
109 /**
110 * Get id
111 *
112 * @return integer
113 */
114 public function getId(): int {
115 return $this->id;
116 }
117
118 /**
119 * Set title
120 *
121 * @param string $title
122 *
123 * @return Location
124 */
125 public function setTitle(string $title): Location {
126 $this->title = $title;
127
128 return $this;
129 }
130
131 /**
132 * Get title
133 *
134 * @return string
135 */
136 public function getTitle(): string {
137 return $this->title;
138 }
139
140 /**
141 * Set description
142 *
143 * @param string $description
144 *
145 * @return Location
146 */
147 public function setDescription(?string $description): Location {
148 $this->description = $description;
149
150 return $this;
151 }
152
153 /**
154 * Get description
155 *
156 * @return string
157 */
158 public function getDescription(): ?string {
159 return $this->description;
160 }
161
162 /**
163 * Set address
164 *
165 * @param string $address
166 *
167 * @return Location
168 */
169 public function setAddress(string $address): Location {
170 $this->address = $address;
171
172 return $this;
173 }
174
175 /**
176 * Get address
177 *
178 * @return string
179 */
180 public function getAddress(): string {
181 return $this->address;
182 }
183
184 /**
185 * Set zipcode
186 *
187 * @param string $zipcode
188 *
189 * @return Location
190 */
191 public function setZipcode(string $zipcode): Location {
192 $this->zipcode = $zipcode;
193
194 return $this;
195 }
196
197 /**
198 * Get zipcode
199 *
200 * @return string
201 */
202 public function getZipcode(): string {
203 return $this->zipcode;
204 }
205
206 /**
207 * Set city
208 *
209 * @param string $city
210 *
211 * @return Location
212 */
213 public function setCity(string $city): Location {
214 $this->city = $city;
215
216 return $this;
217 }
218
219 /**
220 * Get city
221 *
222 * @return string
223 */
224 public function getCity(): string {
225 return $this->city;
226 }
227
228 /**
229 * Set latitude
230 *
231 * @param string $latitude
232 *
233 * @return Location
234 */
235 public function setLatitude(string $latitude): Location {
236 $this->latitude = $latitude;
237
238 return $this;
239 }
240
241 /**
242 * Get latitude
243 *
244 * @return string
245 */
246 public function getLatitude(): string {
247 return $this->latitude;
248 }
249
250 /**
251 * Set longitude
252 *
253 * @param string $longitude
254 *
255 * @return Location
256 */
257 public function setLongitude(string $longitude): Location {
258 $this->longitude = $longitude;
259
260 return $this;
261 }
262
263 /**
264 * Get longitude
265 *
266 * @return string
267 */
268 public function getLongitude(): string {
269 return $this->longitude;
270 }
271
272 /**
273 * Set indoor
274 *
275 * @param bool $indoor
276 *
277 * @return Session
278 */
279 public function setIndoor(bool $indoor): Location {
280 $this->indoor = $indoor;
281
282 return $this;
283 }
284
285 /**
286 * Get indoor
287 *
288 * @return bool
289 */
290 public function getIndoor(): bool {
291 return $this->indoor;
292 }
293
294 /**
295 * Set hotspot
296 *
297 * @param bool $hotspot
298 *
299 * @return Session
300 */
301 public function setHotspot(bool $hotspot): Location {
302 $this->hotspot = $hotspot;
303
304 return $this;
305 }
306
307 /**
308 * Get hotspot
309 *
310 * @return bool
311 */
312 public function getHotspot(): bool {
313 return $this->hotspot;
314 }
315
316 /**
317 * Set created
318 *
319 * @param \DateTime $created
320 *
321 * @return Location
322 */
323 public function setCreated(\DateTime $created): Location {
324 $this->created = $created;
325
326 return $this;
327 }
328
329 /**
330 * Get created
331 *
332 * @return \DateTime
333 */
334 public function getCreated(): \DateTime {
335 return $this->created;
336 }
337
338 /**
339 * Set updated
340 *
341 * @param \DateTime $updated
342 *
343 * @return Location
344 */
345 public function setUpdated(\DateTime $updated): Location {
346 $this->updated = $updated;
347
348 return $this;
349 }
350
351 /**
352 * Get updated
353 *
354 * @return \DateTime
355 */
356 public function getUpdated(): \DateTime {
357 return $this->updated;
358 }
359
360 /**
361 * Add session
362 *
363 * @param Session $session
364 *
365 * @return Location
366 */
367 public function addSession(Session $session): Location {
368 $this->sessions[] = $session;
369
370 return $this;
371 }
372
373 /**
374 * Remove session
375 *
376 * @param Session $session
377 * @return bool
378 */
379 public function removeSession(Session $session): bool {
380 return $this->sessions->removeElement($session);
381 }
382
383 /**
384 * Get sessions
385 *
386 * @return ArrayCollection
387 */
388 public function getSessions(): ArrayCollection {
389 return $this->sessions;
390 }
391
392 /**
393 * Add snippet
394 *
395 * @param Snippet $snippet
396 *
397 * @return Location
398 */
399 public function addSnippet(Snippet $snippet): Location {
400 $this->snippets[] = $snippet;
401
402 return $this;
403 }
404
405 /**
406 * Remove snippet
407 *
408 * @param Snippet $snippet
409 * @return bool
410 */
411 public function removeSnippet(Snippet $snippet): bool {
412 return $this->snippets->removeElement($snippet);
413 }
414
415 /**
416 * Get snippets
417 *
418 * @return ArrayCollection
419 */
420 public function getSnippets(): ArrayCollection {
421 return $this->snippets;
422 }
423
424 /**
425 * Add user
426 *
427 * @param User $user
428 *
429 * @return Location
430 */
431 public function addUser(User $user): Location {
432 $this->users[] = $user;
433
434 return $this;
435 }
436
437 /**
438 * Remove user
439 *
440 * @param User $user
441 * @return bool
442 */
443 public function removeUser(User $user): bool {
444 return $this->users->removeElement($user);
445 }
446
447 /**
448 * Get users
449 *
450 * @return ArrayCollection
451 */
452 public function getUsers(): ArrayCollection {
453 return $this->users;
454 }
455
456 /**
457 * {@inheritdoc}
458 */
459 public function preUpdate(PreUpdateEventArgs $eventArgs) {
460 //Check that we have a location instance
461 if (($location = $eventArgs->getEntity()) instanceof Location) {
462 //Set updated value
463 $location->setUpdated(new \DateTime('now'));
464 }
465 }
466
467 /**
468 * Returns a string representation of the location
469 *
470 * @return string
471 */
472 public function __toString(): string {
473 return $this->title;
474 }
475 }