From c21ece30ad66b4ce32444c7c913bf65883000b66 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 21 May 2021 02:35:59 +0200 Subject: [PATCH] Rename user group join table to users_groups Rename user subscription join table to users_subscriptions Add user location join table users_locations --- Entity/Location.php | 37 +++++++ Entity/User.php | 107 ++++++++++++++------- Resources/config/doctrine/Location.orm.yml | 4 + Resources/config/doctrine/User.orm.yml | 15 ++- 4 files changed, 126 insertions(+), 37 deletions(-) diff --git a/Entity/Location.php b/Entity/Location.php index e57f235..fd61969 100644 --- a/Entity/Location.php +++ b/Entity/Location.php @@ -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 * diff --git a/Entity/User.php b/Entity/User.php index 530ea4d..151f1a1 100644 --- a/Entity/User.php +++ b/Entity/User.php @@ -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; - } } diff --git a/Resources/config/doctrine/Location.orm.yml b/Resources/config/doctrine/Location.orm.yml index 211cbc4..41a3e0c 100644 --- a/Resources/config/doctrine/Location.orm.yml +++ b/Resources/config/doctrine/Location.orm.yml @@ -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: diff --git a/Resources/config/doctrine/User.orm.yml b/Resources/config/doctrine/User.orm.yml index dacee58..fc6431c 100644 --- a/Resources/config/doctrine/User.orm.yml +++ b/Resources/config/doctrine/User.orm.yml @@ -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 -- 2.41.1