]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Config.php
Merge pull request #1478 from K-Phoen/rule-based-tags
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Config.php
index 025d94efb605ee9ff1be2e1f86cadacb536d2d87..2ca4182e6700da790f8f6f02e1fa44701bbee1ed 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace Wallabag\CoreBundle\Entity;
 
+use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\ORM\Mapping as ORM;
 use Symfony\Component\Validator\Constraints as Assert;
 
@@ -9,7 +10,7 @@ use Symfony\Component\Validator\Constraints as Assert;
  * Config.
  *
  * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\ConfigRepository")
- * @ORM\Table
+ * @ORM\Table(name="`config`")
  * @ORM\Entity
  */
 class Config
@@ -72,16 +73,23 @@ class Config
     private $rssLimit;
 
     /**
-     * @ORM\OneToOne(targetEntity="User", inversedBy="config")
+     * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config")
      */
     private $user;
 
+    /**
+     * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\TaggingRule", mappedBy="config", cascade={"remove"})
+     * @ORM\OrderBy({"id" = "ASC"})
+     */
+    private $taggingRules;
+
     /*
      * @param User     $user
      */
-    public function __construct(User $user)
+    public function __construct(\Wallabag\UserBundle\Entity\User $user)
     {
         $this->user = $user;
+        $this->taggingRules = new ArrayCollection();
     }
 
     /**
@@ -169,11 +177,11 @@ class Config
     /**
      * Set user.
      *
-     * @param \Wallabag\CoreBundle\Entity\User $user
+     * @param User $user
      *
      * @return Config
      */
-    public function setUser(\Wallabag\CoreBundle\Entity\User $user = null)
+    public function setUser(\Wallabag\UserBundle\Entity\User $user = null)
     {
         $this->user = $user;
 
@@ -183,7 +191,7 @@ class Config
     /**
      * Get user.
      *
-     * @return \Wallabag\CoreBundle\Entity\User
+     * @return User
      */
     public function getUser()
     {
@@ -237,4 +245,24 @@ class Config
     {
         return $this->rssLimit;
     }
+
+    /**
+     * @param TaggingRule $rule
+     *
+     * @return Config
+     */
+    public function addTaggingRule(TaggingRule $rule)
+    {
+        $this->taggingRules[] = $rule;
+
+        return $this;
+    }
+
+    /**
+     * @return ArrayCollection<TaggingRule>
+     */
+    public function getTaggingRules()
+    {
+        return $this->taggingRules;
+    }
 }