1 <?php
declare(strict_types
=1);
4 * this file is part of the rapsys packbundle package.
6 * (c) raphaël gertz <symfony@rapsys.eu>
8 * for the full copyright and license information, please view the license
9 * file that was distributed with this source code.
12 namespace Rapsys\AirBundle\Entity
;
14 use Doctrine\Common\Collections\ArrayCollection
;
15 use Doctrine\ORM\Event\PreUpdateEventArgs
;
34 protected $description;
82 * @var ArrayCollection
87 * @var ArrayCollection
92 * @var ArrayCollection
99 public function __construct() {
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();
114 public function getId(): int {
121 * @param string $title
125 public function setTitle(string $title): Location
{
126 $this->title
= $title;
136 public function getTitle(): string {
143 * @param string $description
147 public function setDescription(?string $description): Location
{
148 $this->description
= $description;
158 public function getDescription(): ?string {
159 return $this->description
;
165 * @param string $address
169 public function setAddress(string $address): Location
{
170 $this->address
= $address;
180 public function getAddress(): string {
181 return $this->address
;
187 * @param string $zipcode
191 public function setZipcode(string $zipcode): Location
{
192 $this->zipcode
= $zipcode;
202 public function getZipcode(): string {
203 return $this->zipcode
;
209 * @param string $city
213 public function setCity(string $city): Location
{
224 public function getCity(): string {
231 * @param string $latitude
235 public function setLatitude(string $latitude): Location
{
236 $this->latitude
= $latitude;
246 public function getLatitude(): string {
247 return $this->latitude
;
253 * @param string $longitude
257 public function setLongitude(string $longitude): Location
{
258 $this->longitude
= $longitude;
268 public function getLongitude(): string {
269 return $this->longitude
;
275 * @param bool $indoor
279 public function setIndoor(bool $indoor): Location
{
280 $this->indoor
= $indoor;
290 public function getIndoor(): bool {
291 return $this->indoor
;
297 * @param bool $hotspot
301 public function setHotspot(bool $hotspot): Location
{
302 $this->hotspot
= $hotspot;
312 public function getHotspot(): bool {
313 return $this->hotspot
;
319 * @param \DateTime $created
323 public function setCreated(\DateTime
$created): Location
{
324 $this->created
= $created;
334 public function getCreated(): \DateTime
{
335 return $this->created
;
341 * @param \DateTime $updated
345 public function setUpdated(\DateTime
$updated): Location
{
346 $this->updated
= $updated;
356 public function getUpdated(): \DateTime
{
357 return $this->updated
;
363 * @param Session $session
367 public function addSession(Session
$session): Location
{
368 $this->sessions
[] = $session;
376 * @param Session $session
379 public function removeSession(Session
$session): bool {
380 return $this->sessions
->removeElement($session);
386 * @return ArrayCollection
388 public function getSessions(): ArrayCollection
{
389 return $this->sessions
;
395 * @param Snippet $snippet
399 public function addSnippet(Snippet
$snippet): Location
{
400 $this->snippets
[] = $snippet;
408 * @param Snippet $snippet
411 public function removeSnippet(Snippet
$snippet): bool {
412 return $this->snippets
->removeElement($snippet);
418 * @return ArrayCollection
420 public function getSnippets(): ArrayCollection
{
421 return $this->snippets
;
431 public function addUser(User
$user): Location
{
432 //Add from owning side
433 $user->addLocation($this);
435 $this->users
[] = $user;
446 public function removeUser(User
$user): bool {
447 if (!$this->locations
->contains($user)) {
451 //Remove from owning side
452 $user->removeLocation($this);
454 return $this->users
->removeElement($user);
460 * @return ArrayCollection
462 public function getUsers(): ArrayCollection
{
469 public function preUpdate(PreUpdateEventArgs
$eventArgs) {
470 //Check that we have a location instance
471 if (($location = $eventArgs->getObject()) instanceof Location
) {
473 $location->setUpdated(new \
DateTime('now'));
478 * Returns a string representation of the location
482 public function __toString(): string {