]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Entity/Location.php
Fix header comment
[airbundle] / Entity / Location.php
index 4af12808f9cf23e92cd57565941383fe03ee3048..85283df046b4db3323b5396b9d86d07c4eafa922 100644 (file)
@@ -28,6 +28,11 @@ class Location {
         */
        private $title;
 
         */
        private $title;
 
+       /**
+        * @var string
+        */
+       protected $description;
+
        /**
         * @var string
         */
        /**
         * @var string
         */
@@ -54,7 +59,12 @@ class Location {
        private $longitude;
 
        /**
        private $longitude;
 
        /**
-        * @var boolean
+        * @var bool
+        */
+       private $indoor;
+
+       /**
+        * @var bool
         */
        private $hotspot;
 
         */
        private $hotspot;
 
@@ -87,6 +97,10 @@ class Location {
         * Constructor
         */
        public function __construct() {
         * 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();
                $this->sessions = new ArrayCollection();
                $this->snippets = new ArrayCollection();
                $this->users = new ArrayCollection();
@@ -123,6 +137,28 @@ class Location {
                return $this->title;
        }
 
                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
         *
        /**
         * Set address
         *
@@ -233,10 +269,32 @@ class Location {
                return $this->longitude;
        }
 
                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
         *
        /**
         * Set hotspot
         *
-        * @param boolean $hotspot
+        * @param bool $hotspot
         *
         * @return Session
         */
         *
         * @return Session
         */
@@ -249,7 +307,7 @@ class Location {
        /**
         * Get hotspot
         *
        /**
         * Get hotspot
         *
-        * @return boolean
+        * @return bool
         */
        public function getHotspot(): bool {
                return $this->hotspot;
         */
        public function getHotspot(): bool {
                return $this->hotspot;
@@ -316,7 +374,7 @@ class Location {
         * Remove session
         *
         * @param Session $session
         * Remove session
         *
         * @param Session $session
-        * @return boolean
+        * @return bool
         */
        public function removeSession(Session $session): bool {
                return $this->sessions->removeElement($session);
         */
        public function removeSession(Session $session): bool {
                return $this->sessions->removeElement($session);
@@ -348,7 +406,7 @@ class Location {
         * Remove snippet
         *
         * @param Snippet $snippet
         * Remove snippet
         *
         * @param Snippet $snippet
-        * @return boolean
+        * @return bool
         */
        public function removeSnippet(Snippet $snippet): bool {
                return $this->snippets->removeElement($snippet);
         */
        public function removeSnippet(Snippet $snippet): bool {
                return $this->snippets->removeElement($snippet);
@@ -371,6 +429,9 @@ class Location {
         * @return Location
         */
        public function addUser(User $user): Location {
         * @return Location
         */
        public function addUser(User $user): Location {
+               //Add from owning side
+               $user->addLocation($this);
+
                $this->users[] = $user;
 
                return $this;
                $this->users[] = $user;
 
                return $this;
@@ -380,9 +441,16 @@ class Location {
         * Remove user
         *
         * @param User $user
         * Remove user
         *
         * @param User $user
-        * @return boolean
+        * @return bool
         */
        public function removeUser(User $user): bool {
         */
        public function removeUser(User $user): bool {
+               if (!$this->locations->contains($user)) {
+                       return true;
+               }
+
+               //Remove from owning side
+               $user->removeLocation($this);
+
                return $this->users->removeElement($user);
        }
 
                return $this->users->removeElement($user);
        }
 
@@ -400,7 +468,7 @@ class Location {
         */
        public function preUpdate(PreUpdateEventArgs $eventArgs) {
                //Check that we have a location instance
         */
        public function preUpdate(PreUpdateEventArgs $eventArgs) {
                //Check that we have a location instance
-               if (($location = $eventArgs->getEntity()) instanceof Location) {
+               if (($location = $eventArgs->getObject()) instanceof Location) {
                        //Set updated value
                        $location->setUpdated(new \DateTime('now'));
                }
                        //Set updated value
                        $location->setUpdated(new \DateTime('now'));
                }