]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Config.php
Merge remote-tracking branch 'origin/master' into 2.2
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Config.php
index 045ca308ee99991303ae0ecb95c3a0bc7f565cdf..e04f0a7b52714541d1b97e16d61086410480d75b 100644 (file)
 
 namespace Wallabag\CoreBundle\Entity;
 
+use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\ORM\Mapping as ORM;
+use Symfony\Component\Validator\Constraints as Assert;
+use Wallabag\UserBundle\Entity\User;
 
 /**
- * Config
+ * Config.
  *
- * @ORM\Table(name="config")
+ * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\ConfigRepository")
+ * @ORM\Table(name="`config`")
  * @ORM\Entity
  */
 class Config
 {
+    const REDIRECT_TO_HOMEPAGE = 0;
+    const REDIRECT_TO_CURRENT_PAGE = 1;
+
     /**
-     * @var integer
+     * @var int
      *
-     * @ORM\Column(name="id", type="integer", nullable=false)
+     * @ORM\Column(name="id", type="integer")
      * @ORM\Id
-     * @ORM\GeneratedValue(strategy="IDENTITY")
+     * @ORM\GeneratedValue(strategy="AUTO")
      */
     private $id;
 
     /**
      * @var string
      *
-     * @ORM\Column(name="name", type="string", nullable=true)
+     * @Assert\NotBlank()
+     * @ORM\Column(name="theme", type="string", nullable=false)
+     */
+    private $theme;
+
+    /**
+     * @var int
+     *
+     * @Assert\NotBlank()
+     * @Assert\Range(
+     *      min = 1,
+     *      max = 100000,
+     *      maxMessage = "validator.item_per_page_too_high"
+     * )
+     * @ORM\Column(name="items_per_page", type="integer", nullable=false)
+     */
+    private $itemsPerPage;
+
+    /**
+     * @var string
+     *
+     * @Assert\NotBlank()
+     * @ORM\Column(name="language", type="string", nullable=false)
+     */
+    private $language;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="rss_token", type="string", nullable=true)
+     */
+    private $rssToken;
+
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="rss_limit", type="integer", nullable=true)
+     * @Assert\Range(
+     *      min = 1,
+     *      max = 100000,
+     *      maxMessage = "validator.rss_limit_too_high"
+     * )
+     */
+    private $rssLimit;
+
+    /**
+     * @var float
+     *
+     * @ORM\Column(name="reading_speed", type="float", nullable=true)
      */
-    private $name;
+    private $readingSpeed;
 
     /**
      * @var string
      *
-     * @ORM\Column(name="value", type="blob", nullable=true)
+     * @ORM\Column(name="pocket_consumer_key", type="string", nullable=true)
      */
-    private $value;
+    private $pocketConsumerKey;
 
     /**
-     * Get id
+     * @var int
      *
-     * @return integer
+     * @ORM\Column(name="action_mark_as_read", type="integer", nullable=true)
+     */
+    private $actionMarkAsRead;
+
+    /**
+     * @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)
+    {
+        $this->user = $user;
+        $this->taggingRules = new ArrayCollection();
+    }
+
+    /**
+     * Get id.
+     *
+     * @return int
      */
     public function getId()
     {
@@ -46,48 +128,234 @@ class Config
     }
 
     /**
-     * Set name
+     * Set theme.
+     *
+     * @param string $theme
      *
-     * @param  string $name
      * @return Config
      */
-    public function setName($name)
+    public function setTheme($theme)
     {
-        $this->name = $name;
+        $this->theme = $theme;
 
         return $this;
     }
 
     /**
-     * Get name
+     * Get theme.
      *
      * @return string
      */
-    public function getName()
+    public function getTheme()
     {
-        return $this->name;
+        return $this->theme;
     }
 
     /**
-     * Set value
+     * Set itemsPerPage.
+     *
+     * @param int $itemsPerPage
      *
-     * @param  string $value
      * @return Config
      */
-    public function setValue($value)
+    public function setItemsPerPage($itemsPerPage)
     {
-        $this->value = $value;
+        $this->itemsPerPage = $itemsPerPage;
 
         return $this;
     }
 
     /**
-     * Get value
+     * Get itemsPerPage.
+     *
+     * @return int
+     */
+    public function getItemsPerPage()
+    {
+        return $this->itemsPerPage;
+    }
+
+    /**
+     * Set language.
+     *
+     * @param string $language
+     *
+     * @return Config
+     */
+    public function setLanguage($language)
+    {
+        $this->language = $language;
+
+        return $this;
+    }
+
+    /**
+     * Get language.
      *
      * @return string
      */
-    public function getValue()
+    public function getLanguage()
+    {
+        return $this->language;
+    }
+
+    /**
+     * Set user.
+     *
+     * @param User $user
+     *
+     * @return Config
+     */
+    public function setUser(User $user = null)
+    {
+        $this->user = $user;
+
+        return $this;
+    }
+
+    /**
+     * Get user.
+     *
+     * @return User
+     */
+    public function getUser()
+    {
+        return $this->user;
+    }
+
+    /**
+     * Set rssToken.
+     *
+     * @param string $rssToken
+     *
+     * @return Config
+     */
+    public function setRssToken($rssToken)
+    {
+        $this->rssToken = $rssToken;
+
+        return $this;
+    }
+
+    /**
+     * Get rssToken.
+     *
+     * @return string
+     */
+    public function getRssToken()
+    {
+        return $this->rssToken;
+    }
+
+    /**
+     * Set rssLimit.
+     *
+     * @param int $rssLimit
+     *
+     * @return Config
+     */
+    public function setRssLimit($rssLimit)
+    {
+        $this->rssLimit = $rssLimit;
+
+        return $this;
+    }
+
+    /**
+     * Get rssLimit.
+     *
+     * @return int
+     */
+    public function getRssLimit()
+    {
+        return $this->rssLimit;
+    }
+
+    /**
+     * Set readingSpeed.
+     *
+     * @param float $readingSpeed
+     *
+     * @return Config
+     */
+    public function setReadingSpeed($readingSpeed)
+    {
+        $this->readingSpeed = $readingSpeed;
+
+        return $this;
+    }
+
+    /**
+     * Get readingSpeed.
+     *
+     * @return float
+     */
+    public function getReadingSpeed()
+    {
+        return $this->readingSpeed;
+    }
+
+    /**
+     * Set pocketConsumerKey.
+     *
+     * @param string $pocketConsumerKey
+     *
+     * @return Config
+     */
+    public function setPocketConsumerKey($pocketConsumerKey)
+    {
+        $this->pocketConsumerKey = $pocketConsumerKey;
+
+        return $this;
+    }
+
+    /**
+     * Get pocketConsumerKey.
+     *
+     * @return string
+     */
+    public function getPocketConsumerKey()
+    {
+        return $this->pocketConsumerKey;
+    }
+
+    /**
+     * @return int
+     */
+    public function getActionMarkAsRead()
+    {
+        return $this->actionMarkAsRead;
+    }
+
+    /**
+     * @param int $actionMarkAsRead
+     *
+     * @return Config
+     */
+    public function setActionMarkAsRead($actionMarkAsRead)
+    {
+        $this->actionMarkAsRead = $actionMarkAsRead;
+
+        return $this;
+    }
+
+    /**
+     * @param TaggingRule $rule
+     *
+     * @return Config
+     */
+    public function addTaggingRule(TaggingRule $rule)
+    {
+        $this->taggingRules[] = $rule;
+
+        return $this;
+    }
+
+    /**
+     * @return ArrayCollection<TaggingRule>
+     */
+    public function getTaggingRules()
     {
-        return $this->value;
+        return $this->taggingRules;
     }
 }