]> Raphaël G. Git Repositories - airbundle/blobdiff - Entity/Location.php
Add 75006 weather links
[airbundle] / Entity / Location.php
index 43605ed6142ff70fb260a5af6857283f3a19d0c1..57af698c4ced30112a6c7fcd7d67939ffe248967 100644 (file)
@@ -1,7 +1,19 @@
-<?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;
 
 
 namespace Rapsys\AirBundle\Entity;
 
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\ORM\Event\PreUpdateEventArgs;
+
 /**
  * Location
  */
 /**
  * Location
  */
@@ -16,11 +28,6 @@ class Location {
         */
        private $title;
 
         */
        private $title;
 
-       /**
-        * @var string
-        */
-       private $short;
-
        /**
         * @var string
         */
        /**
         * @var string
         */
@@ -46,6 +53,11 @@ class Location {
         */
        private $longitude;
 
         */
        private $longitude;
 
+       /**
+        * @var boolean
+        */
+       private $hotspot;
+
        /**
         * @var \DateTime
         */
        /**
         * @var \DateTime
         */
@@ -57,15 +69,30 @@ class Location {
        private $updated;
 
        /**
        private $updated;
 
        /**
-        * @var \Doctrine\Common\Collections\Collection
+        * @var ArrayCollection
         */
        private $sessions;
 
         */
        private $sessions;
 
+       /**
+        * @var ArrayCollection
+        */
+       private $snippets;
+
+       /**
+        * @var ArrayCollection
+        */
+       private $users;
+
        /**
         * Constructor
         */
        public function __construct() {
        /**
         * Constructor
         */
        public function __construct() {
-               $this->sessions = new \Doctrine\Common\Collections\ArrayCollection();
+               //Set defaults
+               $this->created = new \DateTime('now');
+               $this->updated = new \DateTime('now');
+               $this->sessions = new ArrayCollection();
+               $this->snippets = new ArrayCollection();
+               $this->users = new ArrayCollection();
        }
 
        /**
        }
 
        /**
@@ -73,7 +100,7 @@ class Location {
         *
         * @return integer
         */
         *
         * @return integer
         */
-       public function getId() {
+       public function getId(): int {
                return $this->id;
        }
 
                return $this->id;
        }
 
@@ -84,7 +111,7 @@ class Location {
         *
         * @return Location
         */
         *
         * @return Location
         */
-       public function setTitle($title) {
+       public function setTitle(string $title): Location {
                $this->title = $title;
 
                return $this;
                $this->title = $title;
 
                return $this;
@@ -95,32 +122,10 @@ class Location {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getTitle() {
+       public function getTitle(): string {
                return $this->title;
        }
 
                return $this->title;
        }
 
-       /**
-        * Set short
-        *
-        * @param string $short
-        *
-        * @return Location
-        */
-       public function setShort($short) {
-               $this->short = $short;
-
-               return $this;
-       }
-
-       /**
-        * Get short
-        *
-        * @return string
-        */
-       public function getShort() {
-               return $this->short;
-       }
-
        /**
         * Set address
         *
        /**
         * Set address
         *
@@ -128,7 +133,7 @@ class Location {
         *
         * @return Location
         */
         *
         * @return Location
         */
-       public function setAddress($address) {
+       public function setAddress(string $address): Location {
                $this->address = $address;
 
                return $this;
                $this->address = $address;
 
                return $this;
@@ -139,7 +144,7 @@ class Location {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getAddress() {
+       public function getAddress(): string {
                return $this->address;
        }
 
                return $this->address;
        }
 
@@ -150,7 +155,7 @@ class Location {
         *
         * @return Location
         */
         *
         * @return Location
         */
-       public function setZipcode($zipcode) {
+       public function setZipcode(string $zipcode): Location {
                $this->zipcode = $zipcode;
 
                return $this;
                $this->zipcode = $zipcode;
 
                return $this;
@@ -161,7 +166,7 @@ class Location {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getZipcode() {
+       public function getZipcode(): string {
                return $this->zipcode;
        }
 
                return $this->zipcode;
        }
 
@@ -172,7 +177,7 @@ class Location {
         *
         * @return Location
         */
         *
         * @return Location
         */
-       public function setCity($city) {
+       public function setCity(string $city): Location {
                $this->city = $city;
 
                return $this;
                $this->city = $city;
 
                return $this;
@@ -183,7 +188,7 @@ class Location {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getCity() {
+       public function getCity(): string {
                return $this->city;
        }
 
                return $this->city;
        }
 
@@ -194,7 +199,7 @@ class Location {
         *
         * @return Location
         */
         *
         * @return Location
         */
-       public function setLatitude($latitude) {
+       public function setLatitude(string $latitude): Location {
                $this->latitude = $latitude;
 
                return $this;
                $this->latitude = $latitude;
 
                return $this;
@@ -205,7 +210,7 @@ class Location {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getLatitude() {
+       public function getLatitude(): string {
                return $this->latitude;
        }
 
                return $this->latitude;
        }
 
@@ -216,7 +221,7 @@ class Location {
         *
         * @return Location
         */
         *
         * @return Location
         */
-       public function setLongitude($longitude) {
+       public function setLongitude(string $longitude): Location {
                $this->longitude = $longitude;
 
                return $this;
                $this->longitude = $longitude;
 
                return $this;
@@ -227,10 +232,32 @@ class Location {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getLongitude() {
+       public function getLongitude(): string {
                return $this->longitude;
        }
 
                return $this->longitude;
        }
 
+       /**
+        * Set hotspot
+        *
+        * @param boolean $hotspot
+        *
+        * @return Session
+        */
+       public function setHotspot(bool $hotspot): Location {
+               $this->hotspot = $hotspot;
+
+               return $this;
+       }
+
+       /**
+        * Get hotspot
+        *
+        * @return boolean
+        */
+       public function getHotspot(): bool {
+               return $this->hotspot;
+       }
+
        /**
         * Set created
         *
        /**
         * Set created
         *
@@ -238,7 +265,7 @@ class Location {
         *
         * @return Location
         */
         *
         * @return Location
         */
-       public function setCreated($created) {
+       public function setCreated(\DateTime $created): Location {
                $this->created = $created;
 
                return $this;
                $this->created = $created;
 
                return $this;
@@ -249,7 +276,7 @@ class Location {
         *
         * @return \DateTime
         */
         *
         * @return \DateTime
         */
-       public function getCreated() {
+       public function getCreated(): \DateTime {
                return $this->created;
        }
 
                return $this->created;
        }
 
@@ -260,7 +287,7 @@ class Location {
         *
         * @return Location
         */
         *
         * @return Location
         */
-       public function setUpdated($updated) {
+       public function setUpdated(\DateTime $updated): Location {
                $this->updated = $updated;
 
                return $this;
                $this->updated = $updated;
 
                return $this;
@@ -271,18 +298,18 @@ class Location {
         *
         * @return \DateTime
         */
         *
         * @return \DateTime
         */
-       public function getUpdated() {
+       public function getUpdated(): \DateTime {
                return $this->updated;
        }
 
        /**
         * Add session
         *
                return $this->updated;
        }
 
        /**
         * Add session
         *
-        * @param \Rapsys\AirBundle\Entity\Session $session
+        * @param Session $session
         *
         * @return Location
         */
         *
         * @return Location
         */
-       public function addSession(\Rapsys\AirBundle\Entity\Session $session) {
+       public function addSession(Session $session): Location {
                $this->sessions[] = $session;
 
                return $this;
                $this->sessions[] = $session;
 
                return $this;
@@ -291,21 +318,97 @@ class Location {
        /**
         * Remove session
         *
        /**
         * Remove session
         *
-        * @param \Rapsys\AirBundle\Entity\Session $session
+        * @param Session $session
+        * @return boolean
         */
         */
-       public function removeSession(\Rapsys\AirBundle\Entity\Session $session) {
-               $this->sessions->removeElement($session);
+       public function removeSession(Session $session): bool {
+               return $this->sessions->removeElement($session);
        }
 
        /**
         * Get sessions
         *
        }
 
        /**
         * Get sessions
         *
-        * @return \Doctrine\Common\Collections\Collection
+        * @return ArrayCollection
         */
         */
-       public function getSessions() {
+       public function getSessions(): ArrayCollection {
                return $this->sessions;
        }
 
                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 boolean
+        */
+       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 {
+               $this->users[] = $user;
+
+               return $this;
+       }
+
+       /**
+        * Remove user
+        *
+        * @param User $user
+        * @return boolean
+        */
+       public function removeUser(User $user): bool {
+               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
         *
        /**
         * Returns a string representation of the location
         *