]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/UserBundle/Entity/User.php
First draft to manage relation between User and Group
[github/wallabag/wallabag.git] / src / Wallabag / UserBundle / Entity / User.php
index 7da0d1d5ec05bb3becb78ac0322093ae5fe8fd32..dc10f1c44e8fa17939c3c7c798c5f5a61eada32e 100644 (file)
@@ -98,7 +98,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
     private $authCode;
 
     /**
-     * @ORM\ManyToMany(targetEntity="Wallabag\GroupBundle\Entity\Group")
+     * @ORM\ManyToMany(targetEntity="Wallabag\GroupBundle\Entity\Group", inversedBy="users")
      * @ORM\JoinTable(name="user_group",
      *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
      *      inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}
@@ -319,5 +319,15 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
         if (!empty($this->clients)) {
             return $this->clients->first();
         }
+
+    }
+
+    /**
+     * @param string $name
+     * @return bool
+     */
+    public function hasGroup($name = '')
+    {
+        return in_array($name, $this->getGroupNames());
     }
 }