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