]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/User.php
add relation between user and tags, tests are broken
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / User.php
index 193dfebc25bddfe7472f3dcfb07ee112ad84eb26..f05c8760e03e2780f5cbbf85e302f93fe2327f26 100644 (file)
@@ -7,6 +7,8 @@ use Doctrine\ORM\Mapping as ORM;
 use Symfony\Component\Security\Core\User\UserInterface;
 use Symfony\Component\Security\Core\User\AdvancedUserInterface;
 use Symfony\Component\Validator\Constraints as Assert;
+use JMS\Serializer\Annotation\ExclusionPolicy;
+use JMS\Serializer\Annotation\Expose;
 
 /**
  * User
@@ -14,12 +16,14 @@ use Symfony\Component\Validator\Constraints as Assert;
  * @ORM\Table(name="user")
  * @ORM\Entity
  * @ORM\HasLifecycleCallbacks()
+ * @ExclusionPolicy("all")
  */
 class User implements AdvancedUserInterface, \Serializable
 {
     /**
      * @var integer
      *
+     * @Expose
      * @ORM\Column(name="id", type="integer")
      * @ORM\Id
      * @ORM\GeneratedValue(strategy="AUTO")
@@ -92,10 +96,22 @@ class User implements AdvancedUserInterface, \Serializable
      */
     private $entries;
 
+    /**
+     * @ORM\OneToOne(targetEntity="Config", mappedBy="user")
+     */
+    private $config;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Tag", mappedBy="user", cascade={"remove"})
+     */
+    private $tags;
+
     public function __construct()
     {
-        $this->salt    = md5(uniqid(null, true));
-        $this->entries = new ArrayCollection();
+        $this->isActive = true;
+        $this->salt     = md5(uniqid(null, true));
+        $this->entries  = new ArrayCollection();
+        $this->tags     = new ArrayCollection();
     }
 
     /**
@@ -269,6 +285,25 @@ class User implements AdvancedUserInterface, \Serializable
         return $this->entries;
     }
 
+    /**
+     * @param Entry $entry
+     *
+     * @return User
+     */
+    public function addTag(Tag $tag)
+    {
+        $this->tags[] = $tag;
+
+        return $this;
+    }
+
+    /**
+     * @return ArrayCollection<Tag>
+     */
+    public function getTags()
+    {
+        return $this->tags;
+    }
     /**
      * @inheritDoc
      */
@@ -320,4 +355,26 @@ class User implements AdvancedUserInterface, \Serializable
     {
         return $this->isActive;
     }
+    /**
+     * Set config
+     *
+     * @param  \Wallabag\CoreBundle\Entity\Config $config
+     * @return User
+     */
+    public function setConfig(\Wallabag\CoreBundle\Entity\Config $config = null)
+    {
+        $this->config = $config;
+
+        return $this;
+    }
+
+    /**
+     * Get config
+     *
+     * @return \Wallabag\CoreBundle\Entity\Config
+     */
+    public function getConfig()
+    {
+        return $this->config;
+    }
 }