From: Raphaƫl Gertz Date: Fri, 21 May 2021 00:35:59 +0000 (+0200) Subject: Rename user group join table to users_groups X-Git-Tag: 0.2.3~5 X-Git-Url: https://git.rapsys.eu/airbundle/commitdiff_plain/c21ece30ad66b4ce32444c7c913bf65883000b66?hp=90be6239c556c4462cea5c7f4d977c238d768e4f Rename user group join table to users_groups Rename user subscription join table to users_subscriptions Add user location join table users_locations --- 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