]> Raphaël G. Git Repositories - airbundle/blobdiff - Entity/Location.php
Update translations
[airbundle] / Entity / Location.php
index 4e9ceaf32e142ea7540a3eba6efb76ae5633affa..984e8d86449593b160334a94560d2ddfd34211c3 100644 (file)
-<?php
+<?php declare(strict_types=1);
+
+/*
+ * this file is part of the rapsys packbundle package.
+ *
+ * (c) raphaël gertz <symfony@rapsys.eu>
+ *
+ * for the full copyright and license information, please view the license
+ * file that was distributed with this source code.
+ */
 
 namespace Rapsys\AirBundle\Entity;
 
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\ORM\Event\PreUpdateEventArgs;
+
 /**
  * Location
  */
-class Location
-{
-    /**
-     * @var integer
-     */
-    private $id;
-
-    /**
-     * @var string
-     */
-    private $title;
-
-    /**
-     * @var string
-     */
-    private $address;
-
-    /**
-     * @var string
-     */
-    private $zipcode;
-
-    /**
-     * @var string
-     */
-    private $city;
-
-    /**
-     * @var string
-     */
-    private $latitude;
-
-    /**
-     * @var string
-     */
-    private $longitude;
-
-    /**
-     * @var \DateTime
-     */
-    private $created;
-
-    /**
-     * @var \DateTime
-     */
-    private $updated;
-
-    /**
-     * @var \Doctrine\Common\Collections\Collection
-     */
-    private $sessions;
-
-    /**
-     * Constructor
-     */
-    public function __construct()
-    {
-        $this->sessions = new \Doctrine\Common\Collections\ArrayCollection();
-    }
-
-    /**
-     * Get id
-     *
-     * @return integer
-     */
-    public function getId()
-    {
-        return $this->id;
-    }
-
-    /**
-     * Set title
-     *
-     * @param string $title
-     *
-     * @return Location
-     */
-    public function setTitle($title)
-    {
-        $this->title = $title;
-
-        return $this;
-    }
-
-    /**
-     * Get title
-     *
-     * @return string
-     */
-    public function getTitle()
-    {
-        return $this->title;
-    }
-
-    /**
-     * Set address
-     *
-     * @param string $address
-     *
-     * @return Location
-     */
-    public function setAddress($address)
-    {
-        $this->address = $address;
-
-        return $this;
-    }
-
-    /**
-     * Get address
-     *
-     * @return string
-     */
-    public function getAddress()
-    {
-        return $this->address;
-    }
-
-    /**
-     * Set zipcode
-     *
-     * @param string $zipcode
-     *
-     * @return Location
-     */
-    public function setZipcode($zipcode)
-    {
-        $this->zipcode = $zipcode;
-
-        return $this;
-    }
-
-    /**
-     * Get zipcode
-     *
-     * @return string
-     */
-    public function getZipcode()
-    {
-        return $this->zipcode;
-    }
-
-    /**
-     * Set city
-     *
-     * @param string $city
-     *
-     * @return Location
-     */
-    public function setCity($city)
-    {
-        $this->city = $city;
-
-        return $this;
-    }
-
-    /**
-     * Get city
-     *
-     * @return string
-     */
-    public function getCity()
-    {
-        return $this->city;
-    }
-
-    /**
-     * Set latitude
-     *
-     * @param string $latitude
-     *
-     * @return Location
-     */
-    public function setLatitude($latitude)
-    {
-        $this->latitude = $latitude;
-
-        return $this;
-    }
-
-    /**
-     * Get latitude
-     *
-     * @return string
-     */
-    public function getLatitude()
-    {
-        return $this->latitude;
-    }
-
-    /**
-     * Set longitude
-     *
-     * @param string $longitude
-     *
-     * @return Location
-     */
-    public function setLongitude($longitude)
-    {
-        $this->longitude = $longitude;
-
-        return $this;
-    }
-
-    /**
-     * Get longitude
-     *
-     * @return string
-     */
-    public function getLongitude()
-    {
-        return $this->longitude;
-    }
-
-    /**
-     * Set created
-     *
-     * @param \DateTime $created
-     *
-     * @return Location
-     */
-    public function setCreated($created)
-    {
-        $this->created = $created;
-
-        return $this;
-    }
-
-    /**
-     * Get created
-     *
-     * @return \DateTime
-     */
-    public function getCreated()
-    {
-        return $this->created;
-    }
-
-    /**
-     * Set updated
-     *
-     * @param \DateTime $updated
-     *
-     * @return Location
-     */
-    public function setUpdated($updated)
-    {
-        $this->updated = $updated;
-
-        return $this;
-    }
-
-    /**
-     * Get updated
-     *
-     * @return \DateTime
-     */
-    public function getUpdated()
-    {
-        return $this->updated;
-    }
-
-    /**
-     * Add session
-     *
-     * @param \Rapsys\AirBundle\Entity\Session $session
-     *
-     * @return Location
-     */
-    public function addSession(\Rapsys\AirBundle\Entity\Session $session)
-    {
-        $this->sessions[] = $session;
-
-        return $this;
-    }
-
-    /**
-     * Remove session
-     *
-     * @param \Rapsys\AirBundle\Entity\Session $session
-     */
-    public function removeSession(\Rapsys\AirBundle\Entity\Session $session)
-    {
-        $this->sessions->removeElement($session);
-    }
-
-    /**
-     * Get sessions
-     *
-     * @return \Doctrine\Common\Collections\Collection
-     */
-    public function getSessions()
-    {
-        return $this->sessions;
-    }
+class Location {
+       /**
+        * @var integer
+        */
+       private $id;
+
+       /**
+        * @var string
+        */
+       private $title;
+
+       /**
+        * @var string
+        */
+       protected $description;
+
+       /**
+        * @var string
+        */
+       private $address;
+
+       /**
+        * @var string
+        */
+       private $zipcode;
+
+       /**
+        * @var string
+        */
+       private $city;
+
+       /**
+        * @var string
+        */
+       private $latitude;
+
+       /**
+        * @var string
+        */
+       private $longitude;
+
+       /**
+        * @var bool
+        */
+       private $indoor;
+
+       /**
+        * @var bool
+        */
+       private $hotspot;
+
+       /**
+        * @var \DateTime
+        */
+       private $created;
+
+       /**
+        * @var \DateTime
+        */
+       private $updated;
+
+       /**
+        * @var ArrayCollection
+        */
+       private $sessions;
+
+       /**
+        * @var ArrayCollection
+        */
+       private $snippets;
+
+       /**
+        * @var ArrayCollection
+        */
+       private $users;
+
+       /**
+        * Constructor
+        */
+       public function __construct() {
+               //Set defaults
+               $this->description = null;
+               $this->created = new \DateTime('now');
+               $this->updated = new \DateTime('now');
+               $this->sessions = new ArrayCollection();
+               $this->snippets = new ArrayCollection();
+               $this->users = new ArrayCollection();
+       }
+
+       /**
+        * Get id
+        *
+        * @return integer
+        */
+       public function getId(): int {
+               return $this->id;
+       }
+
+       /**
+        * Set title
+        *
+        * @param string $title
+        *
+        * @return Location
+        */
+       public function setTitle(string $title): Location {
+               $this->title = $title;
+
+               return $this;
+       }
+
+       /**
+        * Get title
+        *
+        * @return string
+        */
+       public function getTitle(): string {
+               return $this->title;
+       }
+
+       /**
+        * Set description
+        *
+        * @param string $description
+        *
+        * @return Location
+        */
+       public function setDescription(?string $description): Location {
+               $this->description = $description;
+
+               return $this;
+       }
+
+       /**
+        * Get description
+        *
+        * @return string
+        */
+       public function getDescription(): ?string {
+               return $this->description;
+       }
+
+       /**
+        * Set address
+        *
+        * @param string $address
+        *
+        * @return Location
+        */
+       public function setAddress(string $address): Location {
+               $this->address = $address;
+
+               return $this;
+       }
+
+       /**
+        * Get address
+        *
+        * @return string
+        */
+       public function getAddress(): string {
+               return $this->address;
+       }
+
+       /**
+        * Set zipcode
+        *
+        * @param string $zipcode
+        *
+        * @return Location
+        */
+       public function setZipcode(string $zipcode): Location {
+               $this->zipcode = $zipcode;
+
+               return $this;
+       }
+
+       /**
+        * Get zipcode
+        *
+        * @return string
+        */
+       public function getZipcode(): string {
+               return $this->zipcode;
+       }
+
+       /**
+        * Set city
+        *
+        * @param string $city
+        *
+        * @return Location
+        */
+       public function setCity(string $city): Location {
+               $this->city = $city;
+
+               return $this;
+       }
+
+       /**
+        * Get city
+        *
+        * @return string
+        */
+       public function getCity(): string {
+               return $this->city;
+       }
+
+       /**
+        * Set latitude
+        *
+        * @param string $latitude
+        *
+        * @return Location
+        */
+       public function setLatitude(string $latitude): Location {
+               $this->latitude = $latitude;
+
+               return $this;
+       }
+
+       /**
+        * Get latitude
+        *
+        * @return string
+        */
+       public function getLatitude(): string {
+               return $this->latitude;
+       }
+
+       /**
+        * Set longitude
+        *
+        * @param string $longitude
+        *
+        * @return Location
+        */
+       public function setLongitude(string $longitude): Location {
+               $this->longitude = $longitude;
+
+               return $this;
+       }
+
+       /**
+        * Get longitude
+        *
+        * @return string
+        */
+       public function getLongitude(): string {
+               return $this->longitude;
+       }
+
+       /**
+        * Set indoor
+        *
+        * @param bool $indoor
+        *
+        * @return Session
+        */
+       public function setIndoor(bool $indoor): Location {
+               $this->indoor = $indoor;
+
+               return $this;
+       }
+
+       /**
+        * Get indoor
+        *
+        * @return bool
+        */
+       public function getIndoor(): bool {
+               return $this->indoor;
+       }
+
+       /**
+        * Set hotspot
+        *
+        * @param bool $hotspot
+        *
+        * @return Session
+        */
+       public function setHotspot(bool $hotspot): Location {
+               $this->hotspot = $hotspot;
+
+               return $this;
+       }
+
+       /**
+        * Get hotspot
+        *
+        * @return bool
+        */
+       public function getHotspot(): bool {
+               return $this->hotspot;
+       }
+
+       /**
+        * Set created
+        *
+        * @param \DateTime $created
+        *
+        * @return Location
+        */
+       public function setCreated(\DateTime $created): Location {
+               $this->created = $created;
+
+               return $this;
+       }
+
+       /**
+        * Get created
+        *
+        * @return \DateTime
+        */
+       public function getCreated(): \DateTime {
+               return $this->created;
+       }
+
+       /**
+        * Set updated
+        *
+        * @param \DateTime $updated
+        *
+        * @return Location
+        */
+       public function setUpdated(\DateTime $updated): Location {
+               $this->updated = $updated;
+
+               return $this;
+       }
+
+       /**
+        * Get updated
+        *
+        * @return \DateTime
+        */
+       public function getUpdated(): \DateTime {
+               return $this->updated;
+       }
+
+       /**
+        * Add session
+        *
+        * @param Session $session
+        *
+        * @return Location
+        */
+       public function addSession(Session $session): Location {
+               $this->sessions[] = $session;
+
+               return $this;
+       }
+
+       /**
+        * Remove session
+        *
+        * @param Session $session
+        * @return bool
+        */
+       public function removeSession(Session $session): bool {
+               return $this->sessions->removeElement($session);
+       }
+
+       /**
+        * Get sessions
+        *
+        * @return ArrayCollection
+        */
+       public function getSessions(): ArrayCollection {
+               return $this->sessions;
+       }
+
+       /**
+        * Add snippet
+        *
+        * @param Snippet $snippet
+        *
+        * @return Location
+        */
+       public function addSnippet(Snippet $snippet): Location {
+               $this->snippets[] = $snippet;
+
+               return $this;
+       }
+
+       /**
+        * Remove snippet
+        *
+        * @param Snippet $snippet
+        * @return bool
+        */
+       public function removeSnippet(Snippet $snippet): bool {
+               return $this->snippets->removeElement($snippet);
+       }
+
+       /**
+        * Get snippets
+        *
+        * @return ArrayCollection
+        */
+       public function getSnippets(): ArrayCollection {
+               return $this->snippets;
+       }
+
+       /**
+        * Add user
+        *
+        * @param User $user
+        *
+        * @return Location
+        */
+       public function addUser(User $user): Location {
+               //Add from owning side
+               $user->addSubscriber($this);
+
+               $this->users[] = $user;
+
+               return $this;
+       }
+
+       /**
+        * Remove user
+        *
+        * @param User $user
+        * @return bool
+        */
+       public function removeUser(User $user): bool {
+               //Remove from owning side
+               $user->removeSubscriber($this);
+
+               return $this->users->removeElement($user);
+       }
+
+       /**
+        * Get users
+        *
+        * @return ArrayCollection
+        */
+       public function getUsers(): ArrayCollection {
+               return $this->users;
+       }
+
+       /**
+        * {@inheritdoc}
+        */
+       public function preUpdate(PreUpdateEventArgs $eventArgs) {
+               //Check that we have a location instance
+               if (($location = $eventArgs->getEntity()) instanceof Location) {
+                       //Set updated value
+                       $location->setUpdated(new \DateTime('now'));
+               }
+       }
+
+       /**
+        * Returns a string representation of the location
+        *
+        * @return string
+        */
+       public function __toString(): string {
+               return $this->title;
+       }
 }
-