]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/User.php
Add LiipThemeBundle
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / User.php
index c83250c37e6d2a2bec25530c1a92667bc72904d1..ed5cfe535ee266b874210ae31673156bc5ff5f11 100644 (file)
@@ -6,6 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection;
 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;
 
 /**
  * User
@@ -29,6 +30,11 @@ class User implements AdvancedUserInterface, \Serializable
      * @var string
      *
      * @ORM\Column(name="username", type="text")
+     * @Assert\NotBlank()
+     * @Assert\Length(
+     *      min = "3",
+     *      max = "255"
+     * )
      */
     private $username;
 
@@ -56,14 +62,16 @@ class User implements AdvancedUserInterface, \Serializable
     /**
      * @var string
      *
-     * @ORM\Column(name="email", type="text", nullable=true)
+     * @ORM\Column(name="email", type="text", nullable=false)
+     * @Assert\Email()
+     * @Assert\NotBlank()
      */
     private $email;
 
     /**
-     * @ORM\Column(name="is_active", type="boolean")
+     * @ORM\Column(name="is_active", type="boolean", nullable=false)
      */
-    private $isActive;
+    private $isActive = true;
 
     /**
      * @var date
@@ -84,11 +92,15 @@ class User implements AdvancedUserInterface, \Serializable
      */
     private $entries;
 
+    /**
+     * @ORM\OneToOne(targetEntity="Config", mappedBy="user")
+     */
+    private $config;
+
     public function __construct()
     {
-        $this->isActive = true;
-        $this->salt     = md5(uniqid(null, true));
-        $this->entries  = new ArrayCollection();
+        $this->salt    = md5(uniqid(null, true));
+        $this->entries = new ArrayCollection();
     }
 
     /**
@@ -313,4 +325,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;
+    }
 }