]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/User.php
CS
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / User.php
index 6a7619ac2ab3addb7892966070cd1d7bd6b0745f..510a1594e2a38821619fb2ee6aa3ce544d647229 100644 (file)
@@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Entity;
 
 use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\ORM\Mapping as ORM;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
 use Symfony\Component\Security\Core\User\UserInterface;
 use Symfony\Component\Security\Core\User\AdvancedUserInterface;
 use Symfony\Component\Validator\Constraints as Assert;
@@ -11,17 +12,20 @@ use JMS\Serializer\Annotation\ExclusionPolicy;
 use JMS\Serializer\Annotation\Expose;
 
 /**
- * User
+ * User.
  *
- * @ORM\Table(name="user")
- * @ORM\Entity
+ * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\UserRepository")
+ * @ORM\Table
  * @ORM\HasLifecycleCallbacks()
  * @ExclusionPolicy("all")
+ *
+ * @UniqueEntity("email")
+ * @UniqueEntity("username")
  */
 class User implements AdvancedUserInterface, \Serializable
 {
     /**
-     * @var integer
+     * @var int
      *
      * @Expose
      * @ORM\Column(name="id", type="integer")
@@ -119,9 +123,9 @@ class User implements AdvancedUserInterface, \Serializable
     public function __construct()
     {
         $this->isActive = true;
-        $this->salt     = md5(uniqid(null, true));
-        $this->entries  = new ArrayCollection();
-        $this->tags     = new ArrayCollection();
+        $this->salt = md5(uniqid(null, true));
+        $this->entries = new ArrayCollection();
+        $this->tags = new ArrayCollection();
     }
 
     /**
@@ -138,9 +142,9 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Get id
+     * Get id.
      *
-     * @return integer
+     * @return int
      */
     public function getId()
     {
@@ -148,9 +152,10 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Set username
+     * Set username.
+     *
+     * @param string $username
      *
-     * @param  string $username
      * @return User
      */
     public function setUsername($username)
@@ -161,7 +166,7 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Get username
+     * Get username.
      *
      * @return string
      */
@@ -171,7 +176,7 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * @inheritDoc
+     * {@inheritdoc}
      */
     public function getSalt()
     {
@@ -179,7 +184,7 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * @inheritDoc
+     * {@inheritdoc}
      */
     public function getRoles()
     {
@@ -187,9 +192,10 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Set password
+     * Set password.
+     *
+     * @param string $password
      *
-     * @param  string $password
      * @return User
      */
     public function setPassword($password)
@@ -204,7 +210,7 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Get password
+     * Get password.
      *
      * @return string
      */
@@ -214,9 +220,10 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Set name
+     * Set name.
+     *
+     * @param string $name
      *
-     * @param  string $name
      * @return User
      */
     public function setName($name)
@@ -227,7 +234,7 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Get name
+     * Get name.
      *
      * @return string
      */
@@ -237,9 +244,10 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Set email
+     * Set email.
+     *
+     * @param string $email
      *
-     * @param  string $email
      * @return User
      */
     public function setEmail($email)
@@ -250,7 +258,7 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Get email
+     * Get email.
      *
      * @return string
      */
@@ -315,7 +323,7 @@ class User implements AdvancedUserInterface, \Serializable
         return $this->tags;
     }
     /**
-     * @inheritDoc
+     * {@inheritdoc}
      */
     public function eraseCredentials()
     {
@@ -337,8 +345,7 @@ class User implements AdvancedUserInterface, \Serializable
     public function unserialize($serialized)
     {
         list(
-            $this->id,
-            ) = unserialize($serialized);
+            $this->id) = unserialize($serialized);
     }
 
     public function isEqualTo(UserInterface $user)
@@ -366,9 +373,10 @@ class User implements AdvancedUserInterface, \Serializable
         return $this->isActive;
     }
     /**
-     * Set config
+     * Set config.
+     *
+     * @param \Wallabag\CoreBundle\Entity\Config $config
      *
-     * @param  \Wallabag\CoreBundle\Entity\Config $config
      * @return User
      */
     public function setConfig(\Wallabag\CoreBundle\Entity\Config $config = null)
@@ -379,7 +387,7 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Get config
+     * Get config.
      *
      * @return \Wallabag\CoreBundle\Entity\Config
      */
@@ -389,9 +397,10 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Set confirmationToken
+     * Set confirmationToken.
+     *
+     * @param string $confirmationToken
      *
-     * @param  string $confirmationToken
      * @return User
      */
     public function setConfirmationToken($confirmationToken)
@@ -402,7 +411,7 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Get confirmationToken
+     * Get confirmationToken.
      *
      * @return string
      */
@@ -412,9 +421,10 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Set passwordRequestedAt
+     * Set passwordRequestedAt.
+     *
+     * @param \DateTime $passwordRequestedAt
      *
-     * @param  \DateTime $passwordRequestedAt
      * @return User
      */
     public function setPasswordRequestedAt($passwordRequestedAt)
@@ -425,7 +435,7 @@ class User implements AdvancedUserInterface, \Serializable
     }
 
     /**
-     * Get passwordRequestedAt
+     * Get passwordRequestedAt.
      *
      * @return \DateTime
      */