]> 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 aba76ca74a262e3ddcc83b90d26519a0af151d2d..dc10f1c44e8fa17939c3c7c798c5f5a61eada32e 100644 (file)
@@ -98,8 +98,16 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
     private $authCode;
 
     /**
-     * @var bool
-     *
+     * @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")}
+     * )
+     */
+    protected $groups;
+
+    /**
+     * @var bool Enabled yes/no
      * @ORM\Column(type="boolean")
      */
     private $twoFactorAuthentication = false;
@@ -311,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());
     }
 }