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