]> Raphaël G. Git Repositories - airbundle/commitdiff
Rename user group join table to users_groups
authorRaphaël Gertz <git@rapsys.eu>
Fri, 21 May 2021 00:35:59 +0000 (02:35 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Fri, 21 May 2021 00:35:59 +0000 (02:35 +0200)
Rename user subscription join table to users_subscriptions
Add user location join table users_locations

Entity/Location.php
Entity/User.php
Resources/config/doctrine/Location.orm.yml
Resources/config/doctrine/User.orm.yml

index e57f235f3f0ef753f85a2c5c4684d47fada90b33..fd619698cbf4ff8b455f70f728bfec446bca5737 100644 (file)
@@ -71,12 +71,18 @@ class Location {
         */
        private $snippets;
 
+       /**
+        * @var \Doctrine\Common\Collections\Collection
+        */
+       private $users;
+
        /**
         * Constructor
         */
        public function __construct() {
                $this->sessions = new \Doctrine\Common\Collections\ArrayCollection();
                $this->snippets = new \Doctrine\Common\Collections\ArrayCollection();
+               $this->users = new \Doctrine\Common\Collections\ArrayCollection();
        }
 
        /**
@@ -370,6 +376,37 @@ class Location {
                return $this->snippets;
        }
 
+       /**
+        * Add user
+        *
+        * @param \Rapsys\AirBundle\Entity\User $user
+        *
+        * @return Location
+        */
+       public function addUser(\Rapsys\AirBundle\Entity\User $user) {
+               $this->users[] = $user;
+
+               return $this;
+       }
+
+       /**
+        * Remove user
+        *
+        * @param \Rapsys\AirBundle\Entity\User $user
+        */
+       public function removeUser(\Rapsys\AirBundle\Entity\User $user) {
+               $this->users->removeElement($user);
+       }
+
+       /**
+        * Get users
+        *
+        * @return \Doctrine\Common\Collections\Collection
+        */
+       public function getUsers() {
+               return $this->users;
+       }
+
        /**
         * Returns a string representation of the location
         *
index 530ea4da0cf7371d4c2e7f38cb9134ce767b7dd4..151f1a10f86662f4c2d9d1724c40bf9a4ad83321 100644 (file)
@@ -23,17 +23,22 @@ class User extends BaseUser {
        /**
         * @var \Doctrine\Common\Collections\Collection
         */
-       private $subscribers;
+       private $locations;
 
        /**
         * @var \Doctrine\Common\Collections\Collection
         */
-       private $subscriptions;
+       private $snippets;
 
        /**
         * @var \Doctrine\Common\Collections\Collection
         */
-       private $snippets;
+       private $subscribers;
+
+       /**
+        * @var \Doctrine\Common\Collections\Collection
+        */
+       private $subscriptions;
 
        /**
         * Constructor
@@ -44,9 +49,10 @@ class User extends BaseUser {
 
                //Set collections
                $this->applications = new \Doctrine\Common\Collections\ArrayCollection();
+               $this->locations = new \Doctrine\Common\Collections\ArrayCollection();
+               $this->snippets = new \Doctrine\Common\Collections\ArrayCollection();
                $this->subscribers = new \Doctrine\Common\Collections\ArrayCollection();
                $this->subscriptions = new \Doctrine\Common\Collections\ArrayCollection();
-               $this->snippets = new \Doctrine\Common\Collections\ArrayCollection();
        }
 
        /**
@@ -146,6 +152,68 @@ class User extends BaseUser {
                return $this->applications;
        }
 
+       /**
+        * Add snippet
+        *
+        * @param \Rapsys\AirBundle\Entity\Snippet $snippet
+        *
+        * @return User
+        */
+       public function addSnippet(Snippet $snippet) {
+               $this->snippets[] = $snippet;
+
+               return $this;
+       }
+
+       /**
+        * Remove snippet
+        *
+        * @param \Rapsys\AirBundle\Entity\Snippet $snippet
+        */
+       public function removeSnippet(Snippet $snippet) {
+               $this->snippets->removeElement($snippet);
+       }
+
+       /**
+        * Get snippets
+        *
+        * @return \Doctrine\Common\Collections\Collection
+        */
+       public function getSnippets() {
+               return $this->snippets;
+       }
+
+       /**
+        * Add location
+        *
+        * @param \Rapsys\AirBundle\Entity\Location $location
+        *
+        * @return User
+        */
+       public function addLocation(Location $location) {
+               $this->locations[] = $location;
+
+               return $this;
+       }
+
+       /**
+        * Remove location
+        *
+        * @param \Rapsys\AirBundle\Entity\Location $location
+        */
+       public function removeLocation(Location $location) {
+               $this->locations->removeElement($location);
+       }
+
+       /**
+        * Get locations
+        *
+        * @return \Doctrine\Common\Collections\Collection
+        */
+       public function getLocations() {
+               return $this->locations;
+       }
+
        /**
         * Add subscriber
         *
@@ -207,35 +275,4 @@ class User extends BaseUser {
        public function getSubscriptions() {
                return $this->subscriptions;
        }
-
-       /**
-        * Add snippet
-        *
-        * @param \Rapsys\AirBundle\Entity\Snippet $snippet
-        *
-        * @return User
-        */
-       public function addSnippet(Snippet $snippet) {
-               $this->snippets[] = $snippet;
-
-               return $this;
-       }
-
-       /**
-        * Remove snippet
-        *
-        * @param \Rapsys\AirBundle\Entity\Snippet $snippet
-        */
-       public function removeSnippet(Snippet $snippet) {
-               $this->snippets->removeElement($snippet);
-       }
-
-       /**
-        * Get snippets
-        *
-        * @return \Doctrine\Common\Collections\Collection
-        */
-       public function getSnippets() {
-               return $this->snippets;
-       }
 }
index 211cbc4295724bda5a928de05306e3dfbf45b05c..41a3e0c7326ace6f77dfd23a4e322c0f1029a943 100644 (file)
@@ -46,6 +46,10 @@ Rapsys\AirBundle\Entity\Location:
         snippets:
             targetEntity: Rapsys\AirBundle\Entity\Snippet
             mappedBy: location
+    manyToMany:
+        users:
+            targetEntity: Rapsys\AirBundle\Entity\User
+            mappedBy: locations
     indexes:
         #XXX: used in SessionRepository::(findAllPendingDailyWeather|findAllPendingHourlyWeather)
         zipcode:
index dacee58c6dfec0ea437942a378dadd2fce858cc7..fc6431c1b2da3f589a53200588d4ea4fc31d93fc 100644 (file)
@@ -19,7 +19,7 @@ Rapsys\AirBundle\Entity\User:
             targetEntity: Rapsys\AirBundle\Entity\User
             inversedBy: subscriptions
             joinTable:
-                name: subscriptions
+                name: users_subscriptions
                 joinColumns:
                     id:
                         name: user_id
@@ -29,6 +29,17 @@ Rapsys\AirBundle\Entity\User:
         subscriptions:
             targetEntity: Rapsys\AirBundle\Entity\User
             mappedBy: subscribers
+        locations:
+            targetEntity: Rapsys\AirBundle\Entity\Location
+            inversedBy: users
+            joinTable:
+                name: users_locations
+                joinColumns:
+                    id:
+                        name: user_id
+                inverseJoinColumns:
+                    id:
+                        name: location_id
 #    manyToMany:
 #        groups:
 #            targetEntity: Group
@@ -38,7 +49,7 @@ Rapsys\AirBundle\Entity\User:
     associationOverride:
         groups:
             joinTable:
-                name: groups_users
+                name: users_groups
                 joinColumns:
                     id:
                         name: user_id